Skip to content

Commit

Permalink
Merge pull request #33610 from owncloud/verify_checksum_bugs
Browse files Browse the repository at this point in the history
[stable10] Fix bugs in checksum verify command
  • Loading branch information
IljaN authored Nov 21, 2018
2 parents 13f3a3a + 8eddbb7 commit 7d6175a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/files/lib/Command/VerifyChecksums.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,39 +90,40 @@ public function execute(InputInterface $input, OutputInterface $output) {
if ($pathOption && $userName) {
$output->writeln('<error>Please use either path or user exclusively</error>');
$this->exitStatus = self::EXIT_INVALID_ARGS;
return $this->exitStatus;
}

$walkFunction = function (Node $node) use ($input, $output) {
$path = $node->getInternalPath();
$currentChecksums = $node->getChecksum();
$owner = $node->getOwner()->getUID();
$storage = $node->getStorage();
$storageId = $storage->getId();

if ($storage->instanceOfStorage(ISharedStorage::class) || $storage->instanceOfStorage(FailedStorage::class)) {
return;
}

if (!self::fileExistsOnDisk($node)) {
$output->writeln("Skipping $owner/$path => File is in file-cache but doesn't exist on storage/disk", OutputInterface::VERBOSITY_VERBOSE);
$output->writeln("Skipping $storageId/$path => File is in file-cache but doesn't exist on storage/disk", OutputInterface::VERBOSITY_VERBOSE);
return;
}

if (!$node->isReadable()) {
$output->writeln("Skipping $owner/$path => File not readable", OutputInterface::VERBOSITY_VERBOSE);
$output->writeln("Skipping $storageId/$path => File not readable", OutputInterface::VERBOSITY_VERBOSE);
return;
}

// Files without calculated checksum can't cause checksum errors
if (empty($currentChecksums)) {
$output->writeln("Skipping $owner/$path => No Checksum", OutputInterface::VERBOSITY_VERBOSE);
$output->writeln("Skipping $storageId/$path => No Checksum", OutputInterface::VERBOSITY_VERBOSE);
return;
}

$output->writeln("Checking $owner/$path => $currentChecksums", OutputInterface::VERBOSITY_VERBOSE);
$output->writeln("Checking $storageId/$path => $currentChecksums", OutputInterface::VERBOSITY_VERBOSE);
$actualChecksums = self::calculateActualChecksums($path, $node->getStorage());
if ($actualChecksums !== $currentChecksums) {
$output->writeln(
"<info>Mismatch for $owner/$path:\n Filecache:\t$currentChecksums\n Actual:\t$actualChecksums</info>"
"<info>Mismatch for $storageId/$path:\n Filecache:\t$currentChecksums\n Actual:\t$actualChecksums</info>"
);

$this->exitStatus = self::EXIT_CHECKSUM_ERRORS;
Expand Down

0 comments on commit 7d6175a

Please sign in to comment.