]> source.dussan.org Git - nextcloud-server.git/commitdiff
check if the old owner and the old path is available
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 19 Dec 2013 17:40:40 +0000 (18:40 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Thu, 19 Dec 2013 17:40:40 +0000 (18:40 +0100)
apps/files_encryption/hooks/hooks.php

index 3e453e210f38c81861eee0004c0e8c39b4c1bc51..09d5687e2269f6d6851211c4613b4390ea3a0608 100644 (file)
@@ -484,7 +484,7 @@ class Hooks {
 \r
        /**\r
         * @brief mark file as renamed so that we know the original source after the file was renamed\r
-        * @param string $path\r
+        * @param array $params with the old path and the new path\r
         */\r
        public static function preRename($params) {\r
                $util = new Util(new \OC_FilesystemView('/'), \OCP\User::getUser());\r
@@ -516,8 +516,15 @@ class Hooks {
                $userId = \OCP\User::getUser();\r
                $util = new Util($view, $userId);\r
 \r
-               $ownerOld = self::$renamedFiles[$params['oldpath']]['uid'];\r
-               $pathOld = self::$renamedFiles[$params['oldpath']]['path'];\r
+               if (isset(self::$renamedFiles[$params['oldpath']]['uid']) &&\r
+                               isset(self::$renamedFiles[$params['oldpath']]['path'])) {\r
+                       $ownerOld = self::$renamedFiles[$params['oldpath']]['uid'];\r
+                       $pathOld = self::$renamedFiles[$params['oldpath']]['path'];\r
+               } else {\r
+                       \OCP\Util::writeLog('Encryption library', "can't get path and owner from the file before it was renamed", \OCP\Util::ERROR);\r
+                       return false;\r
+               }\r
+\r
                list($ownerNew, $pathNew) = $util->getUidAndFilename($params['newpath']);\r
 \r
                // Format paths to be relative to user files dir\r