Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/Analyser/Parallel/ParallelAnalysisNodeExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Boundwize\StructArmed\Cache\AnalysisResultCache;
use Boundwize\StructArmed\Cache\CachePathFactory;
use Boundwize\StructArmed\Progress\ProgressHandlerInterface;
use FilesystemIterator;
use RuntimeException;

use function array_fill;
Expand Down Expand Up @@ -336,13 +335,11 @@ public function extract(
}
}

// when --no-cache is used and no files in the cache directory yet, remove dir cache
// as means only for temporary file for worker needs
// when --no-cache is used, the directory only held worker temporary files:
// remove it best-effort, rmdir() refuses a non-empty directory atomically,
// so a concurrent run's files or an existing cache keep it in place
if (! $this->analysisResultCache instanceof AnalysisResultCache) {
$fileSystemIterator = new FilesystemIterator($cacheDirectory);
if (! $fileSystemIterator->valid()) {
rmdir($cacheDirectory);
}
@rmdir($cacheDirectory);
}

if ($failures !== []) {
Expand Down
9 changes: 3 additions & 6 deletions src/Cache/AnalysisResultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Boundwize\StructArmed\Composer\ComposerJsonProvider;
use Boundwize\StructArmed\Rule\RuleViolation;
use Boundwize\StructArmed\Rule\RuleViolationCollection;
use FilesystemIterator;

use function array_fill_keys;
use function array_is_list;
Expand Down Expand Up @@ -177,11 +176,9 @@ public function clear(): void
}
}

// only remove the cache directory if it is empty
$fileSystemIterator = new FilesystemIterator($this->cacheDirectory);
if (! $fileSystemIterator->valid()) {
rmdir($this->cacheDirectory);
}
// only remove the cache directory if it is empty: rmdir() refuses a
// non-empty directory atomically, so a concurrent run's files keep it
@rmdir($this->cacheDirectory);
}

public function getCacheDirectory(): string
Expand Down
Loading