Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Store first level children in an array to avoid problems
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 6, 2025
commit 1d900495021601564545ee0007508a4abe0a668b
11 changes: 9 additions & 2 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,28 @@ private function getRecursiveDirectoryIterator(string $folder, array $excludedPa
if ($handle === false) {
throw new \Exception('Could not open '.$folder);
}

/* Store first level children in an array to avoid trouble if changes happen while iterating */
$children = [];
while ($name = readdir($handle)) {
if (in_array($name, ['.', '..'])) {
continue;
}
if (isset($exclusions[$name])) {
continue;
}
$children[] = $name;
}

closedir($handle);

foreach ($children as $name) {
$path = $folder.'/'.$name;
if (is_dir($path)) {
yield from $this->getRecursiveDirectoryIterator($path, []);
}
yield $path => new \SplFileInfo($path);
}

closedir($handle);
}

/**
Expand Down
Loading