summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-04-04 11:54:54 +0200
committerGitHub <noreply@github.com>2018-04-04 11:54:54 +0200
commite95184ee258d4d089f7edeae12fd5d465d03d620 (patch)
tree02313a789f3fbd2a3e1bb3156b87332da4cef9ca
parentef14f3c0b04dc1626a8cff49da57fbb57d27cb65 (diff)
parentd4f64b94f28e4ed2c95b235ea4cc2840d1cf000f (diff)
downloadnextcloud-server-e95184ee258d4d089f7edeae12fd5d465d03d620.tar.gz
nextcloud-server-e95184ee258d4d089f7edeae12fd5d465d03d620.zip
Merge pull request #9064 from nextcloud/fix-copy-encrypted-files-stable13
[stable13] reset encryptionVersion to '1' if a file was stream copied
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php15
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php2
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 1ca750f0024..685ecc837bd 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -651,13 +651,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
@@ -665,7 +666,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;
}
@@ -713,7 +714,7 @@ class Encryption extends Wrapper {
$info['size']
);
}
- $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename);
+ $this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, true);
}
return $result;
}
@@ -756,7 +757,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);
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index c184752ff7e..14f4426a9f6 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -806,7 +806,7 @@ class EncryptionTest extends Storage {
'encrypted' => $expectedEncrypted,
];
if($expectedEncrypted === true) {
- $expectedCachePut['encryptedVersion'] = 12345;
+ $expectedCachePut['encryptedVersion'] = 1;
}
$this->arrayCache->expects($this->never())->method('set');