[Pkg-owncloud-commits] [owncloud] 03/122: pass KeyStorage via ctor

David Prévot taffit at moszumanska.debian.org
Sat May 9 00:00:00 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 225cde21830459db044d6564c7a9cf62b7dd5944
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Wed Apr 22 13:09:42 2015 +0200

    pass KeyStorage via ctor
---
 lib/private/encryption/manager.php               |  3 ++-
 lib/private/files/storage/wrapper/encryption.php | 25 ++++++++--------------
 tests/lib/files/storage/wrapper/encryption.php   | 27 +-----------------------
 3 files changed, 12 insertions(+), 43 deletions(-)

diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php
index 7a3f175..97203b7 100644
--- a/lib/private/encryption/manager.php
+++ b/lib/private/encryption/manager.php
@@ -221,7 +221,8 @@ class Manager implements IManager {
 				$logger = \OC::$server->getLogger();
 				$uid = $user ? $user->getUID() : null;
 				$fileHelper = \OC::$server->getEncryptionFilesHelper();
-				return new Encryption($parameters, $manager, $util, $logger, $fileHelper, $uid);
+				$keyStorage = \OC::$server->getEncryptionKeyStorage();
+				return new Encryption($parameters, $manager, $util, $logger, $fileHelper, $uid, $keyStorage);
 			} else {
 				return $storage;
 			}
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index 04eb5fc..0a9e6d6 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -56,6 +56,9 @@ class Encryption extends Wrapper {
 	/** @var IMountPoint */
 	private $mount;
 
+	/** @var \OCP\Encryption\Keys\IStorage */
+	private $keyStorage;
+
 	/**
 	 * @param array $parameters
 	 * @param \OC\Encryption\Manager $encryptionManager
@@ -70,7 +73,8 @@ class Encryption extends Wrapper {
 			\OC\Encryption\Util $util = null,
 			\OC\Log $logger = null,
 			File $fileHelper = null,
-			$uid = null
+			$uid = null,
+			$keyStorage = null
 		) {
 
 		$this->mountPoint = $parameters['mountPoint'];
@@ -80,6 +84,7 @@ class Encryption extends Wrapper {
 		$this->logger = $logger;
 		$this->uid = $uid;
 		$this->fileHelper = $fileHelper;
+		$this->keyStorage = $keyStorage;
 		$this->unencryptedSize = array();
 		parent::__construct($parameters);
 	}
@@ -187,8 +192,7 @@ class Encryption extends Wrapper {
 
 		$encryptionModule = $this->getEncryptionModule($path);
 		if ($encryptionModule) {
-			$keyStorage = $this->getKeyStorage();
-			$keyStorage->deleteAllFileKeys($this->getFullPath($path),
+			$this->keyStorage->deleteAllFileKeys($this->getFullPath($path),
 				$encryptionModule->getId());
 		}
 
@@ -215,8 +219,7 @@ class Encryption extends Wrapper {
 			if (isset($this->unencryptedSize[$source])) {
 				$this->unencryptedSize[$target] = $this->unencryptedSize[$source];
 			}
-			$keyStorage = $this->getKeyStorage();
-			$keyStorage->renameKeys($source, $target);
+			$this->keyStorage->renameKeys($source, $target);
 		}
 
 		return $result;
@@ -241,8 +244,7 @@ class Encryption extends Wrapper {
 			$target = $this->getFullPath($path2);
 			$encryptionModule = $this->getEncryptionModule($path2);
 			if ($encryptionModule) {
-				$keyStorage = $this->getKeyStorage($encryptionModule->getId());
-				$keyStorage->copyKeys($source, $target);
+				$this->keyStorage->copyKeys($source, $target);
 			}
 		}
 
@@ -429,13 +431,4 @@ class Encryption extends Wrapper {
 	public function updateUnencryptedSize($path, $unencryptedSize) {
 		$this->unencryptedSize[$path] = $unencryptedSize;
 	}
-
-	/**
-	 * @param string $encryptionModuleId
-	 * @return \OCP\Encryption\Keys\IStorage
-	 */
-	protected function getKeyStorage() {
-		return \OC::$server->getEncryptionKeyStorage();
-	}
-
 }
diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php
index 228c7b0..1d77655 100644
--- a/tests/lib/files/storage/wrapper/encryption.php
+++ b/tests/lib/files/storage/wrapper/encryption.php
@@ -66,7 +66,7 @@ class Encryption extends \Test\Files\Storage\Storage {
 			->setMethods(['getOption'])
 			->getMock();
 		$mount->expects($this->any())->method('getOption')->willReturn(true);
-		$this->instance = new EncryptionWrapper([
+		$this->instance = new \OC\Files\Storage\Wrapper\Encryption([
 			'storage' => $this->sourceStorage,
 			'root' => 'foo',
 			'mountPoint' => '/',
@@ -105,28 +105,3 @@ class Encryption extends \Test\Files\Storage\Storage {
 		$this->instance->rename('folder', 'flodder');
 	}
 }
-
-//
-// FIXME: this is too bad and needs adjustment
-//
-class EncryptionWrapper extends \OC\Files\Storage\Wrapper\Encryption {
-	private $keyStore;
-
-	public function __construct(
-		$parameters,
-		\OC\Encryption\Manager $encryptionManager = null,
-		\OC\Encryption\Util $util = null,
-		\OC\Log $logger = null,
-		\OC\Encryption\File $fileHelper = null,
-		$uid = null,
-		$keyStore = null
-	) {
-		$this->keyStore = $keyStore;
-		parent::__construct($parameters, $encryptionManager, $util, $logger, $fileHelper, $uid);
-	}
-
-	protected function getKeyStorage() {
-		return $this->keyStore;
-	}
-
-}

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