]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use array_filter instead 22135/head
authorMorris Jobke <hey@morrisjobke.de>
Fri, 7 Aug 2020 08:34:55 +0000 (10:34 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Fri, 7 Aug 2020 08:42:09 +0000 (10:42 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
core/Command/Preview/Repair.php

index 26760cb0e34d53a70b5b3c67ae5e643275a2dac4..852eaeca1d4d93a0705a7302f52e2c666cf7e2c6 100644 (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
                 */
                if ($total < 18) {
-                       foreach ($directoryListing as $index => $dir) {
+                       $directoryListing = array_filter($directoryListing, function ($dir) {
                                if ($dir->getName() === 'old-multibucket') {
-                                       unset($directoryListing[$index]);
+                                       return false;
                                }
+
                                // a-f can't be a file ID -> removing from migration
                                if (preg_match('!^[a-f]$!', $dir->getName())) {
-                                       unset($directoryListing[$index]);
+                                       return false;
                                }
+
                                if (preg_match('!^[0-9]$!', $dir->getName())) {
                                        // ignore folders that only has folders in them
                                        if ($dir instanceof Folder) {
-                                               $hasFile = false;
                                                foreach ($dir->getDirectoryListing() as $entry) {
                                                        if (!$entry instanceof Folder) {
-                                                               $hasFile = true;
-                                                               break;
+                                                               return true;
                                                        }
                                                }
-                                               if (!$hasFile) {
-                                                       unset($directoryListing[$index]);
-                                               }
+                                               return false;
                                        }
                                }
-                       }
+                               return true;
+                       });
                        $total = count($directoryListing);
                }