From 6090807d0b44bddd30473f875dcb9002b79dd169 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Tue, 2 Aug 2022 12:47:26 +0200 Subject: [PATCH] Fix encryption:fix-encrypted-version command when encrypted is set to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../lib/Command/FixEncryptedVersion.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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"); } -- 2.39.5