diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-09-08 22:38:50 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-09-08 22:38:50 +0200 |
commit | 9f11b277976663297e201d81a7051b166968cba0 (patch) | |
tree | 70ab65d19127c3243e13f73de6ea4c562a91a6b3 /lib/private/files/node/folder.php | |
parent | 8958247b4e13078be9898bc6a5ab86a7c67033d3 (diff) | |
download | nextcloud-server-9f11b277976663297e201d81a7051b166968cba0.tar.gz nextcloud-server-9f11b277976663297e201d81a7051b166968cba0.zip |
Use the view logic for getFolderContent for the node api
Diffstat (limited to 'lib/private/files/node/folder.php')
-rw-r--r-- | lib/private/files/node/folder.php | 77 |
1 files changed, 8 insertions, 69 deletions
diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index 042b515fea1..23004fc3527 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -25,7 +25,7 @@ namespace OC\Files\Node; -use OC\Files\Cache\Cache; +use OCP\Files\FileInfo; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; @@ -77,76 +77,15 @@ class Folder extends Node implements \OCP\Files\Folder { * @return Node[] */ public function getDirectoryListing() { - $result = array(); - - /** - * @var \OC\Files\Storage\Storage $storage - */ - list($storage, $internalPath) = $this->view->resolvePath($this->path); - if ($storage) { - $cache = $storage->getCache($internalPath); - - //trigger cache update check - $this->view->getFileInfo($this->path); - - $files = $cache->getFolderContents($internalPath); - } else { - $files = array(); - } - - //add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders - $mounts = $this->root->getMountsIn($this->path); - $dirLength = strlen($this->path); - foreach ($mounts as $mount) { - $subStorage = $mount->getStorage(); - if ($subStorage) { - $subCache = $subStorage->getCache(''); + $folderContent = $this->view->getDirectoryContent($this->path); - if ($subCache->getStatus('') === Cache::NOT_FOUND) { - $subScanner = $subStorage->getScanner(''); - $subScanner->scanFile(''); - } - - $rootEntry = $subCache->get(''); - if ($rootEntry) { - $relativePath = trim(substr($mount->getMountPoint(), $dirLength), '/'); - if ($pos = strpos($relativePath, '/')) { - //mountpoint inside subfolder add size to the correct folder - $entryName = substr($relativePath, 0, $pos); - foreach ($files as &$entry) { - if ($entry['name'] === $entryName) { - if ($rootEntry['size'] >= 0) { - $entry['size'] += $rootEntry['size']; - } else { - $entry['size'] = -1; - } - } - } - } else { //mountpoint in this folder, add an entry for it - $rootEntry['name'] = $relativePath; - $rootEntry['storageObject'] = $subStorage; - - //remove any existing entry with the same name - foreach ($files as $i => $file) { - if ($file['name'] === $rootEntry['name']) { - $files[$i] = null; - break; - } - } - $files[] = $rootEntry; - } - } - } - } - - foreach ($files as $file) { - if ($file) { - $node = $this->createNode($this->path . '/' . $file['name'], $file); - $result[] = $node; + return array_map(function(FileInfo $info) { + if ($info->getMimetype() === 'httpd/unix-directory') { + return new Folder($this->root, $this->view, $info->getPath(), $info); + } else { + return new File($this->root, $this->view, $info->getPath(), $info); } - } - - return $result; + }, $folderContent); } /** |