Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix encryption:fix-encrypted-version command when encrypted is set to 0
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Aug 2, 2022
commit b20278f70834c8f9eee21ab967dd24e69591cd3c
16 changes: 16 additions & 0 deletions apps/encryption/lib/Command/FixEncryptedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,22 @@ private function verifyFileContent(string $path, OutputInterface $output, bool $
$handle = $this->view->fopen($path, 'rb');

if (\fread($handle, 9001) !== false) {
$fileInfo = $this->view->getFileInfo($path);
if (!$fileInfo) {
$output->writeln("<warning>File info not found for file: \"$path\"</warning>");
return true;
}
$encryptedVersion = $fileInfo->getEncryptedVersion();
$stat = $this->view->stat($path);
if (($encryptedVersion == 0) && isset($stat['hasHeader']) && ($stat['hasHeader'] == true)) {
// The file has encrypted to false but has an encryption header
if ($ignoreCorrectEncVersionCall === true) {
// Lets rectify the file by correcting encrypted version
$output->writeln("<info>Attempting to fix the path: \"$path\"</info>");
return $this->correctEncryptedVersion($path, $output);
}
return false;
}
$output->writeln("<info>The file \"$path\" is: OK</info>");
}

Expand Down