[Pkg-owncloud-commits] [owncloud] 42/215: only update share keys if the file was encrypted
David Prévot
taffit at moszumanska.debian.org
Tue May 5 01:01:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 24128d1384f2548f0cdc35c26d684dbeb61d091b
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Fri Apr 24 10:16:06 2015 +0200
only update share keys if the file was encrypted
---
lib/private/encryption/keys/storage.php | 9 +++++++++
lib/private/files/storage/wrapper/encryption.php | 14 ++++++++++----
lib/public/encryption/keys/istorage.php | 2 ++
tests/lib/files/storage/wrapper/encryption.php | 6 ++++--
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php
index e34d737..118c8dc 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 0f6096a..4d54649 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 696d537..ffbffdc 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 f22f02f..2d3f10e 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) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list