summaryrefslogtreecommitdiffstats
path: root/lib/private/encryption
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2015-05-12 13:10:16 +0200
committerBjörn Schießle <bjoern@schiessle.org>2015-05-12 13:10:16 +0200
commitfbe4b77c4946ea4be1ddb3886023f043b8d9eebe (patch)
treefa1d94561b52d3797102d0439b1d813c95f4ff5b /lib/private/encryption
parentb11c0c533e8d447e9193cd618bf11023e6216863 (diff)
parent0d5c7a11e287f44ad556d29b952c57c9ec11dfaa (diff)
downloadnextcloud-server-fbe4b77c4946ea4be1ddb3886023f043b8d9eebe.tar.gz
nextcloud-server-fbe4b77c4946ea4be1ddb3886023f043b8d9eebe.zip
Merge pull request #16228 from owncloud/enc_fix_restore
use hooks to update encryption keys
Diffstat (limited to 'lib/private/encryption')
-rw-r--r--lib/private/encryption/hookmanager.php8
-rw-r--r--lib/private/encryption/update.php34
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');