Browse Source

feat(occ): Add --storage-tree option to info:file to help debug storages

Wrapping can get kind of crazy and this helps understanding the situation

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/44829/head
Côme Chilliet 1 month ago
parent
commit
38e809e635
No account linked to committer's email address
1 changed files with 14 additions and 3 deletions
  1. 14
    3
      core/Command/Info/File.php

+ 14
- 3
core/Command/Info/File.php View File

->setName('info:file') ->setName('info:file')
->setDescription('get information for a file') ->setDescription('get information for a file')
->addArgument('file', InputArgument::REQUIRED, "File id or path") ->addArgument('file', InputArgument::REQUIRED, "File id or path")
->addOption('children', 'c', InputOption::VALUE_NONE, "List children of folders");
->addOption('children', 'c', InputOption::VALUE_NONE, "List children of folders")
->addOption('storage-tree', null, InputOption::VALUE_NONE, "Show storage and cache wrapping tree");
} }


public function execute(InputInterface $input, OutputInterface $output): int { public function execute(InputInterface $input, OutputInterface $output): int {
$output->writeln(" children: " . count($children) . " (use <info>--children</info> option to list)"); $output->writeln(" children: " . count($children) . " (use <info>--children</info> option to list)");
} }
} }
$this->outputStorageDetails($node->getMountPoint(), $node, $output);
$this->outputStorageDetails($node->getMountPoint(), $node, $input, $output);


$filesPerUser = $this->fileUtils->getFilesByUser($node); $filesPerUser = $this->fileUtils->getFilesByUser($node);
$output->writeln(""); $output->writeln("");
* @psalm-suppress UndefinedClass * @psalm-suppress UndefinedClass
* @psalm-suppress UndefinedInterfaceMethod * @psalm-suppress UndefinedInterfaceMethod
*/ */
private function outputStorageDetails(IMountPoint $mountPoint, Node $node, OutputInterface $output): void {
private function outputStorageDetails(IMountPoint $mountPoint, Node $node, InputInterface $input, OutputInterface $output): void {
$storage = $mountPoint->getStorage(); $storage = $mountPoint->getStorage();
if (!$storage) { if (!$storage) {
return; return;
} elseif ($mountPoint instanceof GroupMountPoint) { } elseif ($mountPoint instanceof GroupMountPoint) {
$output->writeln(" groupfolder id: " . $mountPoint->getFolderId()); $output->writeln(" groupfolder id: " . $mountPoint->getFolderId());
} }
if ($input->getOption('storage-tree')) {
$storageTmp = $storage;
$storageClass = get_class($storageTmp).' (cache:'.get_class($storageTmp->getCache()).')';
while ($storageTmp instanceof \OC\Files\Storage\Wrapper\Wrapper) {
$storageTmp = $storageTmp->getWrapperStorage();
$storageClass .= "\n\t".'> '.get_class($storageTmp).' (cache:'.get_class($storageTmp->getCache()).')';
}
$output->writeln(" storage wrapping: " . $storageClass);
}

} }
} }

Loading…
Cancel
Save