summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-05-11 10:35:42 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-05-11 12:06:57 +0200
commit0d5c7a11e287f44ad556d29b952c57c9ec11dfaa (patch)
tree40f6ac27a0253b13e392fae44dce5843fa13fe4b /lib/private
parentebf3953908a8dfdb754a5031d69326c6b83cf609 (diff)
downloadnextcloud-server-0d5c7a11e287f44ad556d29b952c57c9ec11dfaa.tar.gz
nextcloud-server-0d5c7a11e287f44ad556d29b952c57c9ec11dfaa.zip
use hooks to update encryption keys instead of the storage wrapper if a file gets renamed/restored, as long as we
are in the storage wrapper the file cache isn't up-to-date
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/encryption/hookmanager.php8
-rw-r--r--lib/private/encryption/update.php34
-rw-r--r--lib/private/files/storage/wrapper/encryption.php8
3 files changed, 42 insertions, 8 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');
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php
index c0c4c6979c2..c42e6d439fd 100644
--- a/lib/private/files/storage/wrapper/encryption.php
+++ b/lib/private/files/storage/wrapper/encryption.php
@@ -231,13 +231,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);
}
}