From 225cde21830459db044d6564c7a9cf62b7dd5944 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Wed, 22 Apr 2015 13:09:42 +0200 Subject: pass KeyStorage via ctor --- lib/private/files/storage/wrapper/encryption.php | 25 +++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'lib/private/files/storage/wrapper') diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 04eb5fceedd..0a9e6d61d2e 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(); - } - } -- cgit v1.2.3