Skip to content

Commit

Permalink
Fix phpro#912: Ignore deleted files in file_size task
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Michel DELEHAYE committed Nov 25, 2022
1 parent ef3d019 commit fabdccc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Collection/FilesCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ public function ignoreSymlinks(): FilesCollection
});
}

public function ignoreDeleted(): FilesCollection
{
return $this->filter(function (\SplFileInfo $file) {
return $file->isFile();
});
}

/*
* SplFileInfo cannot be serialized. Therefor, we help PHP a bit.
* This stuff is used for running tasks in parallel.
Expand Down
1 change: 1 addition & 0 deletions src/Task/FileSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function run(ContextInterface $context): TaskResultInterface
$maxSize = $config['max_size'];
$files = $context->getFiles()
->ignoreSymlinks()
->ignoreDeleted()
->notPaths($config['ignore_patterns'])
->size(sprintf('>%s', $maxSize));

Expand Down

0 comments on commit fabdccc

Please sign in to comment.