diff options
Diffstat (limited to 'lib/private/encryption')
-rw-r--r-- | lib/private/encryption/hookmanager.php | 8 | ||||
-rw-r--r-- | lib/private/encryption/update.php | 34 |
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/private/encryption/hookmanager.php b/lib/private/encryption/hookmanager.php index c62583b4b47..31ecb2fbcf6 100644 --- a/lib/private/encryption/hookmanager.php +++ b/lib/private/encryption/hookmanager.php @@ -37,6 +37,14 @@ class HookManager { self::getUpdate()->postUnshared($params); } + public static function postRename($params) { + self::getUpdate()->postRename($params); + } + + public static function postRestore($params) { + self::getUpdate()->postRestore($params); + } + /** * @return Update */ diff --git a/lib/private/encryption/update.php b/lib/private/encryption/update.php index ddcee3bae93..02579fd9136 100644 --- a/lib/private/encryption/update.php +++ b/lib/private/encryption/update.php @@ -108,13 +108,45 @@ class Update { } /** + * inform encryption module that a file was restored from the trash bin, + * e.g. to update the encryption keys + * + * @param array $params + */ + public function postRestore($params) { + if ($this->encryptionManager->isEnabled()) { + $path = Filesystem::normalizePath('/' . $this->uid . '/files/' . $params['filePath']); + $this->update($path); + } + } + + /** + * inform encryption module that a file was renamed, + * e.g. to update the encryption keys + * + * @param array $params + */ + public function postRename($params) { + $source = $params['oldpath']; + $target = $params['newpath']; + if( + $this->encryptionManager->isEnabled() && + dirname($source) !== dirname($target) + ) { + list($owner, $ownerPath) = $this->getOwnerPath($target); + $absPath = '/' . $owner . '/files/' . $ownerPath; + $this->update($absPath); + } + } + + /** * get owner and path relative to data/<owner>/files * * @param string $path path to file for current user * @return array ['owner' => $owner, 'path' => $path] * @throw \InvalidArgumentException */ - private function getOwnerPath($path) { + protected function getOwnerPath($path) { $info = Filesystem::getFileInfo($path); $owner = Filesystem::getOwner($path); $view = new View('/' . $owner . '/files'); |