[Pkg-owncloud-commits] [owncloud] 93/122: check if encryption is enbaled before we start moving keys

David Prévot taffit at moszumanska.debian.org
Sat May 9 00:00:22 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 e7a3911c83806f0a11ebf00b96d7498815d718be
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Mon Apr 27 11:40:10 2015 +0200

    check if encryption is enbaled before we start moving keys
---
 lib/private/encryption/update.php                | 24 ++++++-----
 lib/private/files/storage/wrapper/encryption.php | 53 +++++++++++++-----------
 2 files changed, 43 insertions(+), 34 deletions(-)

diff --git a/lib/private/encryption/update.php b/lib/private/encryption/update.php
index a0b0af9..ddcee3b 100644
--- a/lib/private/encryption/update.php
+++ b/lib/private/encryption/update.php
@@ -81,11 +81,13 @@ class Update {
 	 * @param array $params
 	 */
 	public function postShared($params) {
-		if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
-			$path = Filesystem::getPath($params['fileSource']);
-			list($owner, $ownerPath) = $this->getOwnerPath($path);
-			$absPath = '/' . $owner . '/files/' . $ownerPath;
-			$this->update($absPath);
+		if ($this->encryptionManager->isEnabled()) {
+			if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
+				$path = Filesystem::getPath($params['fileSource']);
+				list($owner, $ownerPath) = $this->getOwnerPath($path);
+				$absPath = '/' . $owner . '/files/' . $ownerPath;
+				$this->update($absPath);
+			}
 		}
 	}
 
@@ -95,11 +97,13 @@ class Update {
 	 * @param array $params
 	 */
 	public function postUnshared($params) {
-		if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
-			$path = Filesystem::getPath($params['fileSource']);
-			list($owner, $ownerPath) = $this->getOwnerPath($path);
-			$absPath = '/' . $owner . '/files/' . $ownerPath;
-			$this->update($absPath);
+		if ($this->encryptionManager->isEnabled()) {
+			if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
+				$path = Filesystem::getPath($params['fileSource']);
+				list($owner, $ownerPath) = $this->getOwnerPath($path);
+				$absPath = '/' . $owner . '/files/' . $ownerPath;
+				$this->update($absPath);
+			}
 		}
 	}
 
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 439dc0a..30ef509 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -220,23 +220,23 @@ class Encryption extends Wrapper {
 	 * @return bool
 	 */
 	public function rename($path1, $path2) {
-		$source = $this->getFullPath($path1);
-		if ($this->util->isExcluded($source)) {
-			return $this->storage->rename($path1, $path2);
-		}
 
 		$result = $this->storage->rename($path1, $path2);
-		if ($result) {
-			$target = $this->getFullPath($path2);
-			if (isset($this->unencryptedSize[$source])) {
-				$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
-			}
-			$keysRenamed = $this->keyStorage->renameKeys($source, $target);
-			if ($keysRenamed &&
-				dirname($source) !== dirname($target) &&
-				$this->util->isFile($target)
-			) {
-				$this->update->update($target);
+
+		if ($result && $this->encryptionManager->isEnabled()) {
+			$source = $this->getFullPath($path1);
+			if (!$this->util->isExcluded($source)) {
+				$target = $this->getFullPath($path2);
+				if (isset($this->unencryptedSize[$source])) {
+					$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
+				}
+				$keysRenamed = $this->keyStorage->renameKeys($source, $target);
+				if ($keysRenamed &&
+					dirname($source) !== dirname($target) &&
+					$this->util->isFile($target)
+				) {
+					$this->update->update($target);
+				}
 			}
 		}
 
@@ -251,22 +251,27 @@ class Encryption extends Wrapper {
 	 * @return bool
 	 */
 	public function copy($path1, $path2) {
+
 		$fullPath1 = $this->getFullPath($path1);
 		$fullPath2 = $this->getFullPath($path2);
+		
 		if ($this->util->isExcluded($fullPath1)) {
 			return $this->storage->copy($path1, $path2);
 		}
 
-		$source = $this->getFullPath($path1);
 		$result = $this->storage->copy($path1, $path2);
-		if ($result) {
-			$target = $this->getFullPath($path2);
-			$keysCopied = $this->keyStorage->copyKeys($source, $target);
-			if ($keysCopied &&
-				dirname($source) !== dirname($target) &&
-				$this->util->isFile($target)
-			) {
-				$this->update->update($target);
+
+		if ($result && $this->encryptionManager->isEnabled()) {
+			$source = $this->getFullPath($path1);
+			if (!$this->util->isExcluded($source)) {
+				$target = $this->getFullPath($path2);
+				$keysCopied = $this->keyStorage->copyKeys($source, $target);
+				if ($keysCopied &&
+					dirname($source) !== dirname($target) &&
+					$this->util->isFile($target)
+				) {
+					$this->update->update($target);
+				}
 			}
 			$data = $this->getMetaData($path1);
 			$this->getCache()->put($path2, ['encrypted' => $data['encrypted']]);

-- 
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