From feef3cfa7da8570f88cbadbbf0aae82a243bd95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 2 Sep 2025 16:52:24 +0200 Subject: [PATCH] fix(encryption): Correctly set encrypted to 0 when copying MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If encryption got disabled, copying should set encrypted to 0 for the new unencrypted copy. For instance when using encryption:decrypt-all Signed-off-by: Côme Chilliet --- lib/private/Files/Cache/Cache.php | 11 ++++++++++- lib/private/Files/Storage/Wrapper/Encryption.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index b6b550150f1..c76d0276a47 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -655,6 +655,13 @@ class Cache implements ICache { return $this->storage->instanceOfStorage(Encryption::class); } + protected function shouldEncrypt(string $targetPath): bool { + if (!$this->storage->instanceOfStorage(Encryption::class)) { + return false; + } + return $this->storage->shouldEncrypt($targetPath); + } + /** * Move a file or folder in the cache * @@ -1173,7 +1180,9 @@ class Cache implements ICache { $data = $this->cacheEntryToArray($sourceEntry); // when moving from an encrypted storage to a non-encrypted storage remove the `encrypted` mark - if ($sourceCache instanceof Cache && $sourceCache->hasEncryptionWrapper() && !$this->hasEncryptionWrapper()) { + if ($sourceCache instanceof Cache + && $sourceCache->hasEncryptionWrapper() + && !$this->shouldEncrypt($targetPath)) { $data['encrypted'] = 0; } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index fb6cdf80c6c..0f5c47dae3f 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -884,7 +884,7 @@ class Encryption extends Wrapper { /** * check if the given storage should be encrypted or not */ - protected function shouldEncrypt(string $path): bool { + public function shouldEncrypt(string $path): bool { $fullPath = $this->getFullPath($path); $mountPointConfig = $this->mount->getOption('encrypt', true); if ($mountPointConfig === false) {