]> source.dussan.org Git - nextcloud-server.git/commitdiff
delete old keys if file was moved to a different mount point
authorBjoern Schiessle <schiessle@owncloud.com>
Fri, 28 Nov 2014 16:53:21 +0000 (17:53 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Tue, 2 Dec 2014 15:03:54 +0000 (16:03 +0100)
apps/files_encryption/hooks/hooks.php

index e9d0235d1673bb9834cd473dd79b468da4945a17..53fec11009d37b3416bc81f5997ac65d5160135a 100644 (file)
@@ -432,15 +432,18 @@ class Hooks {
                $mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);\r
                $mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);\r
 \r
-               if ($mp1 === $mp2) {\r
-\r
-                       $oldKeysPath = Keymanager::getKeyPath($view, $util, $params['oldpath']);\r
+               $oldKeysPath = Keymanager::getKeyPath($view, $util, $params['oldpath']);\r
 \r
+               if ($mp1 === $mp2) {\r
                        self::$renamedFiles[$params['oldpath']] = array(\r
                                'operation' => $operation,\r
                                'oldKeysPath' => $oldKeysPath,\r
                                );\r
-\r
+               } else {\r
+                       self::$renamedFiles[$params['oldpath']] = array(\r
+                               'operation' => 'cleanup',\r
+                               'oldKeysPath' => $oldKeysPath,\r
+                               );\r
                }\r
        }\r
 \r
@@ -464,6 +467,9 @@ class Hooks {
                        $operation = self::$renamedFiles[$params['oldpath']]['operation'];\r
                        $oldKeysPath = self::$renamedFiles[$params['oldpath']]['oldKeysPath'];\r
                        unset(self::$renamedFiles[$params['oldpath']]);\r
+                       if ($operation === 'cleanup') {\r
+                               return $view->unlink($oldKeysPath);\r
+                       }\r
                } else {\r
                        \OCP\Util::writeLog('Encryption library', "can't get path and owner from the file before it was renamed", \OCP\Util::DEBUG);\r
                        return false;\r