diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-29 16:27:28 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-29 20:34:45 +0100 |
commit | 0f8fe77b3a7be660e78079bc987bb851b30b576c (patch) | |
tree | 50aa607155be96b17212cfb44cc8e0056a436e31 /lib/private | |
parent | e8ea9a5d276369c83d98ba4efe9bc969d06a9148 (diff) | |
download | nextcloud-server-0f8fe77b3a7be660e78079bc987bb851b30b576c.tar.gz nextcloud-server-0f8fe77b3a7be660e78079bc987bb851b30b576c.zip |
check if the file should really be encrypted before we update the file cache
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encryption.php | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 8531ccc0dd0..c0ccd22d147 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -444,7 +444,7 @@ class Encryption extends Wrapper { } // encryption disabled on write of new file and write to existing unencrypted file -> don't encrypt - if (!$encryptionEnabled || !$this->mount->getOption('encrypt', true)) { + if (!$encryptionEnabled || !$this->shouldEncrypt($path)) { if (!$targetExists || !$targetIsEncrypted) { $shouldEncrypt = false; } @@ -651,7 +651,7 @@ class Encryption extends Wrapper { * @param bool $isRename */ private function updateEncryptedVersion(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename) { - $isEncrypted = $this->encryptionManager->isEnabled() && $this->mount->getOption('encrypt', true) ? 1 : 0; + $isEncrypted = $this->encryptionManager->isEnabled() && $this->shouldEncrypt($targetInternalPath) ? 1 : 0; $cacheInformation = [ 'encrypted' => (bool)$isEncrypted, ]; @@ -954,6 +954,7 @@ class Encryption extends Wrapper { throw $e; } } + return $encryptionModule; } @@ -991,4 +992,31 @@ class Encryption extends Wrapper { return substr($normalized, 0, strlen('/files_versions/')) === '/files_versions/'; } + /** + * check if the given storage should be encrypted or not + * + * @param $path + * @return bool + */ + protected function shouldEncrypt($path) { + $fullPath = $this->getFullPath($path); + $mountPointConfig = $this->mount->getOption('encrypt', true); + if ($mountPointConfig === false) { + return false; + } + + try { + $encryptionModule = $this->getEncryptionModule($fullPath); + } catch (ModuleDoesNotExistsException $e) { + return false; + } + + if ($encryptionModule === null) { + $encryptionModule = $this->encryptionManager->getEncryptionModule(); + } + + return $encryptionModule->shouldEncrypt($fullPath); + + } + } |