diff options
-rw-r--r-- | apps/encryption/lib/keymanager.php | 2 | ||||
-rw-r--r-- | lib/private/encryption/keys/storage.php | 14 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 27 | ||||
-rw-r--r-- | lib/public/encryption/keys/istorage.php | 3 |
4 files changed, 28 insertions, 18 deletions
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php index aa9614812bc..05d23873482 100644 --- a/apps/encryption/lib/keymanager.php +++ b/apps/encryption/lib/keymanager.php @@ -483,7 +483,7 @@ class KeyManager { } public function deleteAllFileKeys($path) { - return $this->keyStorage->deleteAllFileKeys($path, Encryption::ID); + return $this->keyStorage->deleteAllFileKeys($path); } /** diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php index 118c8dc920d..6aa00c5b5ee 100644 --- a/lib/private/encryption/keys/storage.php +++ b/lib/private/encryption/keys/storage.php @@ -125,10 +125,9 @@ class Storage implements IStorage { /** * @inheritdoc */ - public function deleteAllFileKeys($path, $encryptionModuleId) { - $keyDir = $this->getFileKeyDir($encryptionModuleId, $path); - $path = dirname($keyDir); - return !$this->view->file_exists($path) || $this->view->deleteAll($path); + public function deleteAllFileKeys($path) { + $keyDir = $this->getFileKeyDir('', $path); + return !$this->view->file_exists($keyDir) || $this->view->deleteAll($keyDir); } /** @@ -208,17 +207,10 @@ class Storage implements IStorage { * @param string $encryptionModuleId * @param string $path path to the file, relative to data/ * @return string - * @throws GenericEncryptionException - * @internal param string $keyId */ private function getFileKeyDir($encryptionModuleId, $path) { - if ($this->view->is_dir($path)) { - throw new GenericEncryptionException("file was expected but directory was given: $path"); - } - list($owner, $filename) = $this->util->getUidAndFilename($path); - $filename = $this->util->stripPartialFileExtension($filename); // in case of system wide mount points the keys are stored directly in the data directory if ($this->util->isSystemWideMountPoint($filename, $owner)) { diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index c42e6d439fd..f7759d91497 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); @@ -239,6 +238,21 @@ 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); + if ($result && $this->encryptionManager->isEnabled()) { + $this->keyStorage->deleteAllFileKeys($this->getFullPath($path)); + } + + return $result; + } + + /** * see http://php.net/manual/en/function.copy.php * * @param string $path1 @@ -269,8 +283,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; diff --git a/lib/public/encryption/keys/istorage.php b/lib/public/encryption/keys/istorage.php index 752c073375d..17677814107 100644 --- a/lib/public/encryption/keys/istorage.php +++ b/lib/public/encryption/keys/istorage.php @@ -129,12 +129,11 @@ interface IStorage { * delete all file keys for a given file * * @param string $path to the file - * @param string $encryptionModuleId * * @return boolean False when the keys could not be deleted * @since 8.1.0 */ - public function deleteAllFileKeys($path, $encryptionModuleId); + public function deleteAllFileKeys($path); /** * delete system-wide encryption keys not related to a specific user, |