diff options
Diffstat (limited to 'lib/private/encryption/update.php')
-rw-r--r-- | lib/private/encryption/update.php | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/lib/private/encryption/update.php b/lib/private/encryption/update.php index a0b0af968c6..02579fd9136 100644 --- a/lib/private/encryption/update.php +++ b/lib/private/encryption/update.php @@ -81,11 +81,13 @@ class Update { * @param array $params */ public function postShared($params) { - if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { - $path = Filesystem::getPath($params['fileSource']); - list($owner, $ownerPath) = $this->getOwnerPath($path); - $absPath = '/' . $owner . '/files/' . $ownerPath; - $this->update($absPath); + if ($this->encryptionManager->isEnabled()) { + if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { + $path = Filesystem::getPath($params['fileSource']); + list($owner, $ownerPath) = $this->getOwnerPath($path); + $absPath = '/' . $owner . '/files/' . $ownerPath; + $this->update($absPath); + } } } @@ -95,11 +97,45 @@ class Update { * @param array $params */ public function postUnshared($params) { - if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { - $path = Filesystem::getPath($params['fileSource']); - list($owner, $ownerPath) = $this->getOwnerPath($path); - $absPath = '/' . $owner . '/files/' . $ownerPath; - $this->update($absPath); + if ($this->encryptionManager->isEnabled()) { + if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { + $path = Filesystem::getPath($params['fileSource']); + list($owner, $ownerPath) = $this->getOwnerPath($path); + $absPath = '/' . $owner . '/files/' . $ownerPath; + $this->update($absPath); + } + } + } + + /** + * 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); } } @@ -110,7 +146,7 @@ class Update { * @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'); |