]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix shared cache getFolderContents
authorRobin Appelman <icewind@owncloud.com>
Thu, 16 Oct 2014 13:17:12 +0000 (15:17 +0200)
committerRobin Appelman <icewind@owncloud.com>
Fri, 24 Oct 2014 10:32:55 +0000 (12:32 +0200)
apps/files_sharing/lib/cache.php

index e4fd85fd2a7251ab42482ba9350502ea00c16b96..270ed704bbd15c2e682c66cf670aaffe9d35d1da 100644 (file)
@@ -145,26 +145,23 @@ class Shared_Cache extends Cache {
        /**
         * get the metadata of all files stored in $folder
         *
-        * @param string $folder
+        * @param string $folderId
         * @return array
         */
-       public function getFolderContents($folder) {
-
-               if ($folder === false) {
-                       $folder = '';
-               }
-
-               $dir = ($folder !== '') ? $folder . '/' : '';
-
-               $cache = $this->getSourceCache($folder);
+       public function getFolderContentsById($folderId) {
+               $cache = $this->getSourceCache('');
                if ($cache) {
-                       $parent = $this->storage->getFile($folder);
-                       $sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
-                       foreach ($sourceFolderContent as $key => $c) {
-                               $sourceFolderContent[$key]['path'] = $dir . $c['name'];
-                               $sourceFolderContent[$key]['uid_owner'] = $parent['uid_owner'];
-                               $sourceFolderContent[$key]['displayname_owner'] = \OC_User::getDisplayName($parent['uid_owner']);
-                               $sourceFolderContent[$key]['permissions'] = $sourceFolderContent[$key]['permissions'] & $this->storage->getPermissions($dir . $c['name']);
+                       $owner = $this->storage->getSharedFrom();
+                       $parentPath = $this->getPathById($folderId);
+                       if ($parentPath !== '') {
+                               $parentPath .= '/';
+                       }
+                       $sourceFolderContent = $cache->getFolderContentsById($folderId);
+                       foreach ($sourceFolderContent as &$c) {
+                               $c['path'] = ltrim($parentPath . $c['name'], '/');
+                               $c['uid_owner'] = $owner;
+                               $c['displayname_owner'] = \OC_User::getDisplayName($owner);
+                               $c['permissions'] = $c['permissions'] & $this->storage->getPermissions(false);
                        }
 
                        return $sourceFolderContent;