diff options
Diffstat (limited to 'lib/private/files/storage/wrapper/encryption.php')
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index c0c4c6979c2..5d146b2dd1d 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -206,8 +206,7 @@ class Encryption extends Wrapper { $encryptionModule = $this->getEncryptionModule($path); if ($encryptionModule) { - $this->keyStorage->deleteAllFileKeys($this->getFullPath($path), - $encryptionModule->getId()); + $this->keyStorage->deleteAllFileKeys($this->getFullPath($path)); } return $this->storage->unlink($path); @@ -231,13 +230,7 @@ class Encryption extends Wrapper { if (isset($this->unencryptedSize[$source])) { $this->unencryptedSize[$target] = $this->unencryptedSize[$source]; } - $keysRenamed = $this->keyStorage->renameKeys($source, $target); - if ($keysRenamed && - dirname($source) !== dirname($target) && - $this->util->isFile($target) - ) { - $this->update->update($target); - } + $this->keyStorage->renameKeys($source, $target); } } @@ -245,6 +238,49 @@ class Encryption extends Wrapper { } /** + * see http://php.net/manual/en/function.rmdir.php + * + * @param string $path + * @return bool + */ + public function rmdir($path) { + $result = $this->storage->rmdir($path); + $fullPath = $this->getFullPath($path); + if ($result && + $this->util->isExcluded($fullPath) === false && + $this->encryptionManager->isEnabled() + ) { + $this->keyStorage->deleteAllFileKeys($fullPath); + } + + return $result; + } + + /** + * check if a file can be read + * + * @param string $path + * @return bool + */ + public function isReadable($path) { + + $isReadable = true; + + $metaData = $this->getMetaData($path); + if ( + !$this->is_dir($path) && + isset($metaData['encrypted']) && + $metaData['encrypted'] === true + ) { + $fullPath = $this->getFullPath($path); + $module = $this->getEncryptionModule($path); + $isReadable = $module->isReadable($fullPath, $this->uid); + } + + return $this->storage->isReadable($path) && $isReadable; + } + + /** * see http://php.net/manual/en/function.copy.php * * @param string $path1 @@ -275,8 +311,13 @@ class Encryption extends Wrapper { } } $data = $this->getMetaData($path1); - $this->getCache()->put($path2, ['encrypted' => $data['encrypted']]); - $this->updateUnencryptedSize($fullPath2, $data['size']); + + if (isset($data['encrypted'])) { + $this->getCache()->put($path2, ['encrypted' => $data['encrypted']]); + } + if (isset($data['size'])) { + $this->updateUnencryptedSize($fullPath2, $data['size']); + } } return $result; |