summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-11-28 17:53:21 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2014-12-02 16:03:54 +0100
commit2e78217f17fb0c387baeda737b4206130dc00130 (patch)
treeab2f5a524e56e98b5263006ea6c8a309b4656ad2
parent49cfc3035944956269e7264df9fbfb202b7e096d (diff)
downloadnextcloud-server-2e78217f17fb0c387baeda737b4206130dc00130.tar.gz
nextcloud-server-2e78217f17fb0c387baeda737b4206130dc00130.zip
delete old keys if file was moved to a different mount point
-rw-r--r--apps/files_encryption/hooks/hooks.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index e9d0235d167..53fec11009d 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -432,15 +432,18 @@ class Hooks {
$mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);
$mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);
- if ($mp1 === $mp2) {
-
- $oldKeysPath = Keymanager::getKeyPath($view, $util, $params['oldpath']);
+ $oldKeysPath = Keymanager::getKeyPath($view, $util, $params['oldpath']);
+ if ($mp1 === $mp2) {
self::$renamedFiles[$params['oldpath']] = array(
'operation' => $operation,
'oldKeysPath' => $oldKeysPath,
);
-
+ } else {
+ self::$renamedFiles[$params['oldpath']] = array(
+ 'operation' => 'cleanup',
+ 'oldKeysPath' => $oldKeysPath,
+ );
}
}
@@ -464,6 +467,9 @@ class Hooks {
$operation = self::$renamedFiles[$params['oldpath']]['operation'];
$oldKeysPath = self::$renamedFiles[$params['oldpath']]['oldKeysPath'];
unset(self::$renamedFiles[$params['oldpath']]);
+ if ($operation === 'cleanup') {
+ return $view->unlink($oldKeysPath);
+ }
} else {
\OCP\Util::writeLog('Encryption library', "can't get path and owner from the file before it was renamed", \OCP\Util::DEBUG);
return false;