]> source.dussan.org Git - nextcloud-server.git/commitdiff
don't throw exception if a file gets uploaded and encryption is disabled
authorBjoern Schiessle <schiessle@owncloud.com>
Wed, 8 Apr 2015 14:41:20 +0000 (16:41 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Wed, 8 Apr 2015 14:41:20 +0000 (16:41 +0200)
lib/private/files/storage/wrapper/encryption.php

index e4f9781b3827171af77a9b82890f16076e43c3eb..4136e008af95f8f4b9c3e16149a60600cccf41f4 100644 (file)
@@ -226,6 +226,7 @@ class Encryption extends Wrapper {
         */
        public function fopen($path, $mode) {
 
+               $encryptionEnabled = $this->encryptionManager->isEnabled();
                $shouldEncrypt = false;
                $encryptionModule = null;
                $header = $this->getHeader($path);
@@ -258,10 +259,11 @@ class Encryption extends Wrapper {
                        ) {
                                if (!empty($encryptionModuleId)) {
                                        $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId);
-                               } else {
+                                       $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath);
+                               } elseif ($encryptionEnabled) {
                                        $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
+                                       $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath);
                                }
-                               $shouldEncrypt = $encryptionModule->shouldEncrypt($fullPath);
                        } else {
                                // only get encryption module if we found one in the header
                                if (!empty($encryptionModuleId)) {
@@ -271,12 +273,11 @@ class Encryption extends Wrapper {
                        }
                } catch (ModuleDoesNotExistsException $e) {
                        $this->logger->warning('Encryption module "' . $encryptionModuleId .
-                               '" not found, file will be stored unencrypted');
+                               '" not found, file will be stored unencrypted (' . $e->getMessage() . ')');
                }
 
                // encryption disabled on write of new file and write to existing unencrypted file -> don't encrypt
-               $encEnabled = $this->encryptionManager->isEnabled();
-               if (!$encEnabled || !$this->mount->getOption('encrypt', true)) {
+               if (!$encryptionEnabled || !$this->mount->getOption('encrypt', true)) {
                        if (!$targetExists || !$targetIsEncrypted) {
                                $shouldEncrypt = false;
                        }