From: Côme Chilliet Date: Tue, 2 Aug 2022 10:47:26 +0000 (+0200) Subject: Fix encryption:fix-encrypted-version command when encrypted is set to 0 X-Git-Tag: v24.0.5rc1~24^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6090807d0b44bddd30473f875dcb9002b79dd169;p=nextcloud-server.git Fix encryption:fix-encrypted-version command when encrypted is set to 0 Signed-off-by: Côme Chilliet --- diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php index b3c0d8c4d16..d4c5eddbfe5 100644 --- a/apps/encryption/lib/Command/FixEncryptedVersion.php +++ b/apps/encryption/lib/Command/FixEncryptedVersion.php @@ -175,6 +175,22 @@ class FixEncryptedVersion extends Command { $handle = $this->view->fopen($path, 'rb'); if (\fread($handle, 9001) !== false) { + $fileInfo = $this->view->getFileInfo($path); + if (!$fileInfo) { + $output->writeln("File info not found for file: \"$path\""); + 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("Attempting to fix the path: \"$path\""); + return $this->correctEncryptedVersion($path, $output); + } + return false; + } $output->writeln("The file \"$path\" is: OK"); }