aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Storage/Wrapper
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-12-05 15:38:13 +0100
committerGitHub <noreply@github.com>2016-12-05 15:38:12 +0100
commit1253d1008ad22417b1a0c49d327c7ba0c68d4103 (patch)
tree788f6d71528e562a6d13d98366663e00e05ac6d9 /lib/private/Files/Storage/Wrapper
parent86a53b4e191f6cb497429343a94e659e1c975bb4 (diff)
parent0f8fe77b3a7be660e78079bc987bb851b30b576c (diff)
downloadnextcloud-server-1253d1008ad22417b1a0c49d327c7ba0c68d4103.tar.gz
nextcloud-server-1253d1008ad22417b1a0c49d327c7ba0c68d4103.zip
Merge pull request #2411 from nextcloud/fix-encryption-home-storage
check if the file should really be encrypted before we update the file cache
Diffstat (limited to 'lib/private/Files/Storage/Wrapper')
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php32
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);
+
+ }
+
}