summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-03-28 16:27:29 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-04-03 18:01:23 +0200
commita0923d9ffb3f6827fefdef91e14992fd7d452ede (patch)
tree0679d58ba3d986f534a1df62e709345d1bdba4a1 /lib/private
parented239d72dc51b4b50eaec1ab8bbeb2e5cf6249b7 (diff)
downloadnextcloud-server-a0923d9ffb3f6827fefdef91e14992fd7d452ede.tar.gz
nextcloud-server-a0923d9ffb3f6827fefdef91e14992fd7d452ede.zip
reset encryptionVersion to '1' if a file was stream copied, because this means that we basically write the file from scratch
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index b65db054055..488218e8e74 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -652,13 +652,14 @@ class Encryption extends Wrapper {
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @param bool $isRename
+ * @param bool $keepEncryptionVersion
*/
- private function updateEncryptedVersion(Storage\IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename) {
- $isEncrypted = $this->encryptionManager->isEnabled() && $this->shouldEncrypt($targetInternalPath) ? 1 : 0;
+ private function updateEncryptedVersion(Storage\IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, $keepEncryptionVersion) {
+ $isEncrypted = $this->encryptionManager->isEnabled() && $this->shouldEncrypt($targetInternalPath);
$cacheInformation = [
- 'encrypted' => (bool)$isEncrypted,
+ 'encrypted' => $isEncrypted,
];
- if($isEncrypted === 1) {
+ if($isEncrypted) {
$encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion'];
// In case of a move operation from an unencrypted to an encrypted
@@ -666,7 +667,7 @@ class Encryption extends Wrapper {
// correct value would be "1". Thus we manually set the value to "1"
// for those cases.
// See also https://github.com/owncloud/core/issues/23078
- if($encryptedVersion === 0) {
+ if($encryptedVersion === 0 || !$keepEncryptionVersion) {
$encryptedVersion = 1;
}
@@ -714,7 +715,7 @@ class Encryption extends Wrapper {
$info['size']
);
}
- $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename);
+ $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, true);
}
return $result;
}
@@ -757,7 +758,7 @@ class Encryption extends Wrapper {
if ($preserveMtime) {
$this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
}
- $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename);
+ $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, false);
} else {
// delete partially written target file
$this->unlink($targetInternalPath);