aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-04-14 16:39:50 +0200
committerRobin Appelman <robin@icewind.nl>2023-04-17 16:23:52 +0200
commitc5dfa1cb797ea7fdb09f31963974edebb30742fe (patch)
tree303269109a555267ebf8596bf62195c5a679bdb5 /core
parent60cf0c8f5fc5d61f926765f95ff40625349ec787 (diff)
downloadnextcloud-server-c5dfa1cb797ea7fdb09f31963974edebb30742fe.tar.gz
nextcloud-server-c5dfa1cb797ea7fdb09f31963974edebb30742fe.zip
validate that folder size sums to children
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'core')
-rw-r--r--core/Command/Info/File.php26
1 files changed, 21 insertions, 5 deletions
diff --git a/core/Command/Info/File.php b/core/Command/Info/File.php
index 15aa885e2fe..bf7b9ae4e0a 100644
--- a/core/Command/Info/File.php
+++ b/core/Command/Info/File.php
@@ -40,7 +40,7 @@ class File extends Command {
parent::__construct();
}
- protected function configure() {
+ protected function configure(): void {
$this
->setName('info:file')
->setDescription('get information for a file')
@@ -61,17 +61,24 @@ class File extends Command {
$output->writeln(" fileid: " . $node->getId());
$output->writeln(" mimetype: " . $node->getMimetype());
$output->writeln(" modified: " . (string)$this->l10n->l("datetime", $node->getMTime()));
- $output->writeln(" size: " . Util::humanFileSize($node->getSize()));
$output->writeln(" " . ($node->isEncrypted() ? "encrypted" : "not encrypted"));
+ $output->writeln(" size: " . Util::humanFileSize($node->getSize()));
if ($node instanceof Folder) {
$children = $node->getDirectoryListing();
+ $childSize = array_sum(array_map(function (Node $node) {
+ return $node->getSize();
+ }, $children));
+ if ($childSize != $node->getSize()) {
+ $output->writeln(" <error>warning: folder has a size of " . Util::humanFileSize($node->getSize()) ." but it's children sum up to " . Util::humanFileSize($childSize) . "</error>.");
+ $output->writeln(" Run <info>occ files:scan --path " . $node->getPath() . "</info> to attempt to resolve this.");
+ }
if ($showChildren) {
$output->writeln(" children: " . count($children) . ":");
foreach ($children as $child) {
$output->writeln(" - " . $child->getName());
}
} else {
- $output->writeln(" children: " . count($children) . " (--children to list)");
+ $output->writeln(" children: " . count($children) . " (use <info>--children</info> option to list)");
}
}
$this->outputStorageDetails($node->getMountPoint(), $node, $output);
@@ -156,6 +163,10 @@ class File extends Command {
return implode(", ", $perms);
}
+ /**
+ * @psalm-suppress UndefinedClass
+ * @psalm-suppress UndefinedInterfaceMethod
+ */
private function formatMountType(IMountPoint $mountPoint): string {
$storage = $mountPoint->getStorage();
if ($storage && $storage->instanceOfStorage(IHomeStorage::class)) {
@@ -176,7 +187,7 @@ class File extends Command {
$description .= " owned by " . $share->getShareOwner();
}
return $description;
- } elseif ($mountPoint instanceof GroupMountPoint) { /** @psalm-suppress UndefinedClass */
+ } elseif ($mountPoint instanceof GroupMountPoint) {
return "groupfolder " . $mountPoint->getFolderId();
} elseif ($mountPoint instanceof ExternalMountPoint) {
return "external storage " . $mountPoint->getStorageConfig()->getId();
@@ -203,6 +214,10 @@ class File extends Command {
}
}
+ /**
+ * @psalm-suppress UndefinedClass
+ * @psalm-suppress UndefinedInterfaceMethod
+ */
private function outputStorageDetails(IMountPoint $mountPoint, Node $node, OutputInterface $output): void {
$storage = $mountPoint->getStorage();
if (!$storage) {
@@ -215,6 +230,7 @@ class File extends Command {
/** @var ObjectStoreStorage $storage */
$objectStoreId = $storage->getObjectStore()->getStorageId();
$parts = explode(':', $objectStoreId);
+ /** @var string $bucket */
$bucket = array_pop($parts);
$output->writeln(" bucket: " . $bucket);
if ($node instanceof \OC\Files\Node\File) {
@@ -242,7 +258,7 @@ class File extends Command {
$storageConfig = $mountPoint->getStorageConfig();
$output->writeln(" external storage id: " . $storageConfig->getId());
$output->writeln(" external type: " . $storageConfig->getBackend()->getText());
- } elseif ($mountPoint instanceof GroupMountPoint) { /** @psalm-suppress UndefinedClass */
+ } elseif ($mountPoint instanceof GroupMountPoint) {
$output->writeln(" groupfolder id: " . $mountPoint->getFolderId());
}
}