From d600955a51a9536ac9ebfa7198ef963679153740 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Apr 2015 11:11:52 +0200 Subject: Make getDefaultModuleId public and get module protected --- lib/private/encryption/manager.php | 14 +++++--------- lib/private/encryption/update.php | 2 +- lib/private/files/storage/wrapper/encryption.php | 6 ++---- lib/public/encryption/imanager.php | 7 +++---- 4 files changed, 11 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php index c10867c3da8..1a42646daf6 100644 --- a/lib/private/encryption/manager.php +++ b/lib/private/encryption/manager.php @@ -158,7 +158,7 @@ class Manager implements IManager { * @return \OCP\Encryption\IEncryptionModule * @throws Exceptions\ModuleDoesNotExistsException */ - public function getDefaultEncryptionModule() { + protected function getDefaultEncryptionModule() { $defaultModuleId = $this->getDefaultEncryptionModuleId(); if (!empty($defaultModuleId)) { if (isset($this->encryptionModules[$defaultModuleId])) { @@ -183,12 +183,12 @@ class Manager implements IManager { public function setDefaultEncryptionModule($moduleId) { try { $this->getEncryptionModule($moduleId); - $this->config->setAppValue('core', 'default_encryption_module', $moduleId); - return true; } catch (\Exception $e) { return false; } + $this->config->setAppValue('core', 'default_encryption_module', $moduleId); + return true; } /** @@ -196,12 +196,8 @@ class Manager implements IManager { * * @return string */ - protected function getDefaultEncryptionModuleId() { - try { - return $this->config->getAppValue('core', 'default_encryption_module'); - } catch (\Exception $e) { - return ''; - } + public function getDefaultEncryptionModuleId() { + return $this->config->getAppValue('core', 'default_encryption_module'); } public static function setupStorage() { diff --git a/lib/private/encryption/update.php b/lib/private/encryption/update.php index f262099a3c5..a0b0af968c6 100644 --- a/lib/private/encryption/update.php +++ b/lib/private/encryption/update.php @@ -137,7 +137,7 @@ class Update { $allFiles = array($path); } - $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule(); + $encryptionModule = $this->encryptionManager->getEncryptionModule(); foreach ($allFiles as $file) { $usersSharing = $this->file->getAccessList($file); diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 0dc59cbb2a0..af48d3475c3 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -311,12 +311,10 @@ class Encryption extends Wrapper { || $mode === 'wb' || $mode === 'wb+' ) { - if (!empty($encryptionModuleId)) { + if ($encryptionEnabled) { + // if $encryptionModuleId is empty, the default module will be used $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId); $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath); - } elseif ($encryptionEnabled) { - $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule(); - $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath); } } else { // only get encryption module if we found one in the header diff --git a/lib/public/encryption/imanager.php b/lib/public/encryption/imanager.php index 3a370710781..3cb30f8ee89 100644 --- a/lib/public/encryption/imanager.php +++ b/lib/public/encryption/imanager.php @@ -78,13 +78,12 @@ interface IManager { function getEncryptionModule($moduleId); /** - * get default encryption module + * get default encryption module Id * - * @return \OCP\Encryption\IEncryptionModule - * @throws ModuleDoesNotExistsException + * @return string * @since 8.1.0 */ - public function getDefaultEncryptionModule(); + public function getDefaultEncryptionModuleId(); /** * set default encryption module Id -- cgit v1.2.3