Use array_filter instead

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2020-08-07 10:34:55 +02:00
parent 97c49b0b15
commit 545f806666
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
1 changed files with 9 additions and 10 deletions

View File

@ -112,30 +112,29 @@ class Repair extends Command {
* by default there could be 0-9 a-f and the old-multibucket folder which are all fine * by default there could be 0-9 a-f and the old-multibucket folder which are all fine
*/ */
if ($total < 18) { if ($total < 18) {
foreach ($directoryListing as $index => $dir) { $directoryListing = array_filter($directoryListing, function ($dir) {
if ($dir->getName() === 'old-multibucket') { if ($dir->getName() === 'old-multibucket') {
unset($directoryListing[$index]); return false;
} }
// a-f can't be a file ID -> removing from migration // a-f can't be a file ID -> removing from migration
if (preg_match('!^[a-f]$!', $dir->getName())) { if (preg_match('!^[a-f]$!', $dir->getName())) {
unset($directoryListing[$index]); return false;
} }
if (preg_match('!^[0-9]$!', $dir->getName())) { if (preg_match('!^[0-9]$!', $dir->getName())) {
// ignore folders that only has folders in them // ignore folders that only has folders in them
if ($dir instanceof Folder) { if ($dir instanceof Folder) {
$hasFile = false;
foreach ($dir->getDirectoryListing() as $entry) { foreach ($dir->getDirectoryListing() as $entry) {
if (!$entry instanceof Folder) { if (!$entry instanceof Folder) {
$hasFile = true; return true;
break;
} }
} }
if (!$hasFile) { return false;
unset($directoryListing[$index]);
}
} }
} }
} return true;
});
$total = count($directoryListing); $total = count($directoryListing);
} }