summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-04-21 15:22:22 +0200
committerRobin Appelman <robin@icewind.nl>2023-05-25 13:34:16 +0200
commit670bd08af093d23fe0232d1e64bf38480b796e18 (patch)
tree419f5121d8398e64ae716657cc5b6c8229cebf9b /core
parent75d9dba48fbfeb7416752721677d7e35595dd40a (diff)
downloadnextcloud-server-670bd08af093d23fe0232d1e64bf38480b796e18.tar.gz
nextcloud-server-670bd08af093d23fe0232d1e64bf38480b796e18.zip
add option to list all files instead of limiting
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'core')
-rw-r--r--core/Command/Info/File.php2
-rw-r--r--core/Command/Info/FileUtils.php30
-rw-r--r--core/Command/Info/Space.php10
3 files changed, 23 insertions, 19 deletions
diff --git a/core/Command/Info/File.php b/core/Command/Info/File.php
index 8ca7a3d0264..20d8cbffc94 100644
--- a/core/Command/Info/File.php
+++ b/core/Command/Info/File.php
@@ -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;
diff --git a/core/Command/Info/FileUtils.php b/core/Command/Info/FileUtils.php
index e4793bdfd2a..1264dee5de2 100644
--- a/core/Command/Info/FileUtils.php
+++ b/core/Command/Info/FileUtils.php
@@ -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;
}
diff --git a/core/Command/Info/Space.php b/core/Command/Info/Space.php
index 36821ac521f..7f901ee729b 100644
--- a/core/Command/Info/Space.php
+++ b/core/Command/Info/Space.php
@@ -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;
}
-
}