Permalink
Browse files

Adding a file_exists() check before unlinking cache files.

This prevents issues where two concurrent requests could
be clearing the same cache files.
Fixes #1936
  • Loading branch information...
1 parent 1a872e6 commit 4a7bd031e5b637fe0049ae9b569c284849f67c2f @markstory markstory committed Aug 27, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/Cake/Cache/Engine/FileEngine.php
@@ -240,7 +240,9 @@ public function clear($check) {
}
$path = $this->_File->getRealPath();
$this->_File = null;
- unlink($path);
+ if (file_exists($path)) {
+ unlink($path);
+ }
}
$dir->close();
return true;

2 comments on commit 4a7bd03

Contributor

davidsteinsland replied Sep 6, 2013

This does not help with the race conditions. The only way to fix the problem is by:

@unlink ($path);

Not even if (file_exists ($path)).

Owner

markstory replied Sep 6, 2013

Thanks, did you want to do a pull request to improve this?

Please sign in to comment.