diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index c58387bbc2cf5..e386412352923 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -704,6 +704,16 @@ private function updateEncryptedVersion(Storage\IStorage $sourceStorage, $source */ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, $isRename) { + // store encryptedVersion + $encrypted = false; + $encryptedVersion = 0; + if (isset($sourceStorage->getCache()->get($sourceInternalPath)['encrypted'])) { + $encrypted = $sourceStorage->getCache()->get($sourceInternalPath)['encrypted']; + } + if (isset($sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion'])) { + $encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion']; + } + // for versions we have nothing to do, because versions should always use the // key from the original file. Just create a 1:1 copy and done if ($this->isVersion($targetInternalPath) || @@ -774,6 +784,10 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte $this->getCache()->remove($targetInternalPath); } } + + // restore encryptedVersion + $sourceStorage->getCache()->put($sourceInternalPath, ['encrypted' => $encrypted, 'encryptedVersion' => $encryptedVersion]); + return (bool)$result; } @@ -1020,7 +1034,7 @@ protected function shouldEncrypt($path) { } try { - $encryptionModule = $this->getEncryptionModule($fullPath); + $encryptionModule = $this->getEncryptionModule($path); } catch (ModuleDoesNotExistsException $e) { return false; }