Skip to content

Commit

Permalink
Merge pull request #9253 from kkmuffme/fix-lstat-bug-when-removing-ca…
Browse files Browse the repository at this point in the history
…che-dir

fix lstat bug cache directory race condition
  • Loading branch information
orklah committed Feb 11, 2023
2 parents 8e3ba6a + 78c3d6b commit 93267f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
use function fclose;
use function file_exists;
use function file_get_contents;
use function filetype;
use function flock;
use function fopen;
use function get_class;
Expand Down Expand Up @@ -2502,11 +2501,12 @@ public static function removeCacheDirectory(string $dir): void
$full_path = $dir . '/' . $object;

// if it was deleted in the meantime/race condition with other psalm process
clearstatcache(true, $full_path);
if (!file_exists($full_path)) {
continue;
}

if (filetype($full_path) === 'dir') {
if (is_dir($full_path)) {
self::removeCacheDirectory($full_path);
} else {
$fp = fopen($full_path, 'c');
Expand Down

0 comments on commit 93267f2

Please sign in to comment.