]> source.dussan.org Git - nextcloud-server.git/commitdiff
add option to list all files instead of limiting 37865/head
authorRobin Appelman <robin@icewind.nl>
Fri, 21 Apr 2023 13:22:22 +0000 (15:22 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 4 May 2023 11:10:26 +0000 (13:10 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
core/Command/Info/File.php
core/Command/Info/FileUtils.php
core/Command/Info/Space.php
lib/composer/composer/autoload_classmap.php
lib/composer/composer/autoload_static.php

index 8ca7a3d0264ee4059362c102eca6b605ae10ff6d..20d8cbffc94e4ef7d2262d4c862d9f004bd744ec 100644 (file)
@@ -7,10 +7,8 @@ namespace OC\Core\Command\Info;
 use OC\Files\ObjectStore\ObjectStoreStorage;
 use OCA\Files_External\Config\ExternalMountPoint;
 use OCA\GroupFolders\Mount\GroupMountPoint;
-use OCP\Files\Config\IUserMountCache;
 use OCP\Files\Folder;
 use OCP\Files\IHomeStorage;
-use OCP\Files\IRootFolder;
 use OCP\Files\Mount\IMountPoint;
 use OCP\Files\Node;
 use OCP\Files\NotFoundException;
index e4793bdfd2a755831f9766e0ee7a2318da6b801c..1264dee5de21bd9d80786cc8ae9077965802d631 100644 (file)
@@ -23,7 +23,6 @@ declare(strict_types=1);
 
 namespace OC\Core\Command\Info;
 
-
 use OC\Files\SetupManager;
 use OCA\Circles\MountManager\CircleMount;
 use OCA\Files_External\Config\ExternalMountPoint;
@@ -195,7 +194,8 @@ class FileUtils {
                OutputInterface $output,
                Folder $node,
                string $prefix,
-               array &$sizeLimits
+               array &$sizeLimits,
+               bool $all,
        ): int {
                /**
                 * Algorithm to print the N largest items in a folder without requiring to query or sort the entire three
@@ -220,25 +220,31 @@ class FileUtils {
                        return $b->getSize() <=> $a->getSize();
                });
                foreach ($children as $i => $child) {
-                       if (count($sizeLimits) === 0 || $child->getSize() < $sizeLimits[0]) {
-                               return $count;
+                       if (!$all) {
+                               if (count($sizeLimits) === 0 || $child->getSize() < $sizeLimits[0]) {
+                                       return $count;
+                               }
+                               array_shift($sizeLimits);
                        }
-                       array_shift($sizeLimits);
                        $count += 1;
 
                        /** @var Node $child */
                        $output->writeln("$prefix- " . $child->getName() . ": <info>" . Util::humanFileSize($child->getSize()) . "</info>");
                        if ($child instanceof Folder) {
                                $recurseSizeLimits = $sizeLimits;
-                               for ($j = 0; $j < count($recurseSizeLimits); $j++) {
-                                       $nextChildSize = (int)$children[$i + $j + 1]?->getSize();
-                                       if ($nextChildSize > $recurseSizeLimits[0]) {
-                                               array_shift($recurseSizeLimits);
-                                               $recurseSizeLimits[] = $nextChildSize;
+                               if (!$all) {
+                                       for ($j = 0; $j < count($recurseSizeLimits); $j++) {
+                                               if (isset($children[$i + $j + 1])) {
+                                                       $nextChildSize = $children[$i + $j + 1]->getSize();
+                                                       if ($nextChildSize > $recurseSizeLimits[0]) {
+                                                               array_shift($recurseSizeLimits);
+                                                               $recurseSizeLimits[] = $nextChildSize;
+                                                       }
+                                               }
                                        }
+                                       sort($recurseSizeLimits);
                                }
-                               sort($recurseSizeLimits);
-                               $recurseCount = $this->outputLargeFilesTree($output, $child, $prefix . "  ", $recurseSizeLimits);
+                               $recurseCount = $this->outputLargeFilesTree($output, $child, $prefix . "  ", $recurseSizeLimits, $all);
                                $sizeLimits = array_slice($sizeLimits, $recurseCount);
                                $count += $recurseCount;
                        }
index 36821ac521f61cc104b3de900aa175890e02fb4e..7f901ee729b593b0ddc69127451dc2da8f73192f 100644 (file)
@@ -23,7 +23,6 @@ declare(strict_types=1);
 
 namespace OC\Core\Command\Info;
 
-
 use OCP\Files\Folder;
 use OCP\Util;
 use Symfony\Component\Console\Command\Command;
@@ -45,12 +44,14 @@ class Space extends Command {
                        ->setName('info:file:space')
                        ->setDescription('Summarize space usage of specified folder')
                        ->addArgument('file', InputArgument::REQUIRED, "File id or path")
-                       ->addOption('count', 'c', InputOption::VALUE_REQUIRED, "Number of items to display", 25);
+                       ->addOption('count', 'c', InputOption::VALUE_REQUIRED, "Number of items to display", 25)
+                       ->addOption('all', 'a', InputOption::VALUE_NONE, "Display all items");
        }
 
        public function execute(InputInterface $input, OutputInterface $output): int {
                $fileInput = $input->getArgument('file');
                $count = (int)$input->getOption('count');
+               $all = $input->getOption('all');
                $node = $this->fileUtils->getNode($fileInput);
                if (!$node) {
                        $output->writeln("<error>file $fileInput not found</error>");
@@ -58,10 +59,9 @@ class Space extends Command {
                }
                $output->writeln($node->getName() . ": <info>" . Util::humanFileSize($node->getSize()) . "</info>");
                if ($node instanceof Folder) {
-                       $limits = array_fill(0, $count - 1, 0);
-                       $this->fileUtils->outputLargeFilesTree($output, $node, '', $limits);
+                       $limits = $all ? [] : array_fill(0, $count - 1, 0);
+                       $this->fileUtils->outputLargeFilesTree($output, $node, '', $limits, $all);
                }
                return 0;
        }
-
 }
index 83eef30eed1f035eed31768d01d9f3b69d71c389..95118a895e8c1507a2971b89f4417a5b938b4152 100644 (file)
@@ -960,6 +960,8 @@ return array(
     'OC\\Core\\Command\\Group\\ListCommand' => $baseDir . '/core/Command/Group/ListCommand.php',
     'OC\\Core\\Command\\Group\\RemoveUser' => $baseDir . '/core/Command/Group/RemoveUser.php',
     'OC\\Core\\Command\\Info\\File' => $baseDir . '/core/Command/Info/File.php',
+    'OC\\Core\\Command\\Info\\FileUtils' => $baseDir . '/core/Command/Info/FileUtils.php',
+    'OC\\Core\\Command\\Info\\Space' => $baseDir . '/core/Command/Info/Space.php',
     'OC\\Core\\Command\\Integrity\\CheckApp' => $baseDir . '/core/Command/Integrity/CheckApp.php',
     'OC\\Core\\Command\\Integrity\\CheckCore' => $baseDir . '/core/Command/Integrity/CheckCore.php',
     'OC\\Core\\Command\\Integrity\\SignApp' => $baseDir . '/core/Command/Integrity/SignApp.php',
index 1f97b5518f9c7c489dedeadd619b87ab2d67a666..5293cf90f078131892932eb4992e223413ff9806 100644 (file)
@@ -993,6 +993,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
         'OC\\Core\\Command\\Group\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/Group/ListCommand.php',
         'OC\\Core\\Command\\Group\\RemoveUser' => __DIR__ . '/../../..' . '/core/Command/Group/RemoveUser.php',
         'OC\\Core\\Command\\Info\\File' => __DIR__ . '/../../..' . '/core/Command/Info/File.php',
+        'OC\\Core\\Command\\Info\\FileUtils' => __DIR__ . '/../../..' . '/core/Command/Info/FileUtils.php',
+        'OC\\Core\\Command\\Info\\Space' => __DIR__ . '/../../..' . '/core/Command/Info/Space.php',
         'OC\\Core\\Command\\Integrity\\CheckApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckApp.php',
         'OC\\Core\\Command\\Integrity\\CheckCore' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckCore.php',
         'OC\\Core\\Command\\Integrity\\SignApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/SignApp.php',