diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-03 16:31:11 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-03 16:31:11 +0100 |
commit | 8d2238e0559be894a4b836d3371dbdae5696e5eb (patch) | |
tree | c46fc21d687c259eded3869cb45df376961d2ac9 /lib | |
parent | a0df1bb0219f74539a771e710ff516399cee05f3 (diff) | |
parent | 72c8187cbb24b460edf7d1c5c2cbfaee12c22fd6 (diff) | |
download | nextcloud-server-8d2238e0559be894a4b836d3371dbdae5696e5eb.tar.gz nextcloud-server-8d2238e0559be894a4b836d3371dbdae5696e5eb.zip |
Merge pull request #22796 from owncloud/fix-encryption-on-version-restore
Keep "encryptedVersion" when calling `\OC\Files\View::copy`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 7e9ada4174a..0b4816174bf 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -621,6 +621,32 @@ class Encryption extends Wrapper { } /** + * Update the encrypted cache version in the database + * + * @param Storage $sourceStorage + * @param string $sourceInternalPath + * @param string $targetInternalPath + * @param bool $isRename + */ + private function updateEncryptedVersion(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename) { + $isEncrypted = $this->encryptionManager->isEnabled() && $this->mount->getOption('encrypt', true) ? 1 : 0; + $cacheInformation = [ + 'encrypted' => (bool)$isEncrypted, + ]; + if($isEncrypted === 1) { + $cacheInformation['encryptedVersion'] = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion']; + } + + // in case of a rename we need to manipulate the source cache because + // this information will be kept for the new target + if ($isRename) { + $sourceStorage->getCache()->put($sourceInternalPath, $cacheInformation); + } else { + $this->getCache()->put($targetInternalPath, $cacheInformation); + } + } + + /** * copy file between two storages * * @param Storage $sourceStorage @@ -647,6 +673,7 @@ class Encryption extends Wrapper { $info['size'] ); } + $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename); } return $result; } @@ -689,15 +716,7 @@ class Encryption extends Wrapper { if ($preserveMtime) { $this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath)); } - $isEncrypted = $this->encryptionManager->isEnabled() && $this->mount->getOption('encrypt', true) ? 1 : 0; - - // in case of a rename we need to manipulate the source cache because - // this information will be kept for the new target - if ($isRename) { - $sourceStorage->getCache()->put($sourceInternalPath, ['encrypted' => $isEncrypted]); - } else { - $this->getCache()->put($targetInternalPath, ['encrypted' => $isEncrypted]); - } + $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename); } else { // delete partially written target file $this->unlink($targetInternalPath); |