summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-24 10:16:06 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-24 10:19:09 +0200
commit24128d1384f2548f0cdc35c26d684dbeb61d091b (patch)
tree3ae27c27d8c681ce45b6b2ac1fe8315125e631c6
parent2646bccb83d06f575722e3fb8c5bd87ed42775c9 (diff)
downloadnextcloud-server-24128d1384f2548f0cdc35c26d684dbeb61d091b.tar.gz
nextcloud-server-24128d1384f2548f0cdc35c26d684dbeb61d091b.zip
only update share keys if the file was encrypted
-rw-r--r--lib/private/encryption/keys/storage.php9
-rw-r--r--lib/private/files/storage/wrapper/encryption.php14
-rw-r--r--lib/public/encryption/keys/istorage.php2
-rw-r--r--tests/lib/files/storage/wrapper/encryption.php6
4 files changed, 25 insertions, 6 deletions
diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php
index e34d7370ef1..118c8dc920d 100644
--- a/lib/private/encryption/keys/storage.php
+++ b/lib/private/encryption/keys/storage.php
@@ -235,6 +235,7 @@ class Storage implements IStorage {
*
* @param string $source
* @param string $target
+ * @return boolean
*/
public function renameKeys($source, $target) {
@@ -253,7 +254,11 @@ class Storage implements IStorage {
if ($this->view->file_exists($sourcePath)) {
$this->keySetPreparation(dirname($targetPath));
$this->view->rename($sourcePath, $targetPath);
+
+ return true;
}
+
+ return false;
}
/**
@@ -261,6 +266,7 @@ class Storage implements IStorage {
*
* @param string $source
* @param string $target
+ * @return boolean
*/
public function copyKeys($source, $target) {
@@ -279,7 +285,10 @@ class Storage implements IStorage {
if ($this->view->file_exists($sourcePath)) {
$this->keySetPreparation(dirname($targetPath));
$this->view->copy($sourcePath, $targetPath);
+ return true;
}
+
+ return false;
}
/**
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 0f6096adb76..4d546495aaa 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -230,8 +230,11 @@ class Encryption extends Wrapper {
if (isset($this->unencryptedSize[$source])) {
$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
}
- $this->keyStorage->renameKeys($source, $target);
- if (dirname($source) !== dirname($target) && $this->util->isFile($target)) {
+ $keysRenamed = $this->keyStorage->renameKeys($source, $target);
+ if ($keysRenamed &&
+ dirname($source) !== dirname($target) &&
+ $this->util->isFile($target)
+ ) {
$this->update->update($target);
}
}
@@ -256,8 +259,11 @@ class Encryption extends Wrapper {
$result = $this->storage->copy($path1, $path2);
if ($result) {
$target = $this->getFullPath($path2);
- $this->keyStorage->copyKeys($source, $target);
- if (dirname($source) !== dirname($target) && $this->util->isFile($target)) {
+ $keysCopied = $this->keyStorage->copyKeys($source, $target);
+ if ($keysCopied &&
+ dirname($source) !== dirname($target) &&
+ $this->util->isFile($target)
+ ) {
$this->update->update($target);
}
}
diff --git a/lib/public/encryption/keys/istorage.php b/lib/public/encryption/keys/istorage.php
index 696d5373310..ffbffdc1a27 100644
--- a/lib/public/encryption/keys/istorage.php
+++ b/lib/public/encryption/keys/istorage.php
@@ -153,6 +153,7 @@ interface IStorage {
*
* @param string $source
* @param string $target
+ * @return boolean
* @since 8.1.0
*/
public function renameKeys($source, $target);
@@ -162,6 +163,7 @@ interface IStorage {
*
* @param string $source
* @param string $target
+ * @retrun boolean
* @since 8.1.0
*/
public function copyKeys($source, $target);
diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php
index f22f02f568c..2d3f10ecdfa 100644
--- a/tests/lib/files/storage/wrapper/encryption.php
+++ b/tests/lib/files/storage/wrapper/encryption.php
@@ -136,7 +136,8 @@ class Encryption extends \Test\Files\Storage\Storage {
public function testRename($source, $target, $shouldUpdate) {
$this->keyStore
->expects($this->once())
- ->method('renameKeys');
+ ->method('renameKeys')
+ ->willReturn(true);
$this->util->expects($this->any())
->method('isFile')->willReturn(true);
if ($shouldUpdate) {
@@ -174,7 +175,8 @@ class Encryption extends \Test\Files\Storage\Storage {
public function testCopy($source, $target, $shouldUpdate) {
$this->keyStore
->expects($this->once())
- ->method('copyKeys');
+ ->method('copyKeys')
+ ->willReturn(true);
$this->util->expects($this->any())
->method('isFile')->willReturn(true);
if ($shouldUpdate) {