]> source.dussan.org Git - nextcloud-server.git/commitdiff
backport of #3527
authorFlorin Peter <github@florin-peter.de>
Wed, 29 May 2013 17:11:39 +0000 (19:11 +0200)
committerFlorin Peter <github@florin-peter.de>
Fri, 31 May 2013 10:27:38 +0000 (12:27 +0200)
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/util.php

index 955425595ba523dedc7e41e39b6d58f3177554b1..9893cecc94e32924ecca6db1a2d3363b1a5365ba 100644 (file)
@@ -329,6 +329,13 @@ class Hooks {
 \r
                        // if a folder was shared, get a list of all (sub-)folders\r
                        if ($params['itemType'] === 'folder') {\r
+\r
+                               // get the path including mount point only if not a shared folder\r
+                               if(strncmp($path, '/Shared' , strlen('/Shared') !== 0)) {\r
+                                       // get path including the the storage mount point\r
+                                       $path = $util->getPathWithMountPoint($params['itemSource']);\r
+                               }\r
+\r
                                $allFiles = $util->getAllFiles($path);\r
                        } else {\r
                                $allFiles = array($path);\r
@@ -405,10 +412,16 @@ class Hooks {
                        }\r
 \r
                        // if we unshare a folder we need a list of all (sub-)files\r
-                       if ($params['itemType'] === 'folder') {\r
+                       if ( $params['itemType'] === 'folder' ) {\r
 \r
-                               $allFiles = $util->getAllFiles($path);\r
+                               // get the path including mount point only if not a shared folder\r
+                               if(strncmp($path, '/Shared' , strlen('/Shared') !== 0)) {\r
+                                       // get path including the the storage mount point\r
+                                       $path = $util->getPathWithMountPoint($params['itemSource']);\r
+                               }\r
 \r
+                               $allFiles = $util->getAllFiles( $path );\r
+                               \r
                        } else {\r
 \r
                                $allFiles = array($path);\r
index 2c99d5d502db2bbd557dc656b041ebd570a6e39b..0c1421a471b10d75635ef8659ba04d6d90ac9bb2 100644 (file)
@@ -1199,7 +1199,7 @@ class Util {
 
                $result = array();
 
-               $content = $this->view->getDirectoryContent($this->userFilesDir . $dir);
+               $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath($this->userFilesDir . '/' . $dir));
 
                // handling for re shared folders
                $path_split = explode('/', $dir);
@@ -1535,4 +1535,22 @@ class Util {
                $this->recoverAllFiles('/', $privateKey);
        }
 
+       /**
+        * Get the path including the storage mount point
+        * @param int $id
+        * @return string the path including the mount point like AmazonS3/folder/file.txt
+        */
+       public function getPathWithMountPoint($id) {
+               list($storage, $internalPath) = \OC\Files\Cache\Cache::getById($id);
+               $mount = \OC\Files\Filesystem::getMountByStorageId($storage);
+               $mountPoint = $mount[0]->getMountPoint();
+               $path = \OC\Files\Filesystem::normalizePath($mountPoint.'/'.$internalPath);
+
+               // reformat the path to be relative e.g. /user/files/folder becomes /folder/
+               $pathSplit = explode( '/', $path );
+               $relativePath = implode( '/', array_slice( $pathSplit, 3 ) );
+
+               return $relativePath;
+       }
+
 }