diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-03-21 14:20:33 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-03-21 14:20:33 +0100 |
commit | 0b0b3253bb75f5fffb39201da39139d4f26d8a22 (patch) | |
tree | 3a9d6cc07be19420c2af8c5de7e2b4097b5ed327 /lib | |
parent | d0dd76bb8ac904cff425d4c32f2033951e3a2ba5 (diff) | |
download | nextcloud-server-0b0b3253bb75f5fffb39201da39139d4f26d8a22.tar.gz nextcloud-server-0b0b3253bb75f5fffb39201da39139d4f26d8a22.zip |
properly use fileinfo objects
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/node/folder.php | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index c376bfb1881..f4d7dae20a3 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -90,14 +90,14 @@ class Folder extends Node implements \OCP\Files\Folder { /** * @param string $path - * @param array $info + * @param FileInfo $info * @return File|Folder */ - protected function createNode($path, $info = array()) { - if (!isset($info['mimetype'])) { + protected function createNode($path, FileInfo $info = null) { + if (is_null($info)) { $isDir = $this->view->is_dir($path); } else { - $isDir = $info['mimetype'] === 'httpd/unix-directory'; + $isDir = $info->getType() === FileInfo::TYPE_FOLDER; } if ($isDir) { return new Folder($this->root, $this->view, $path, $info); @@ -211,10 +211,9 @@ class Folder extends Node implements \OCP\Files\Folder { private function searchCommon($method, $args) { $files = array(); $rootLength = strlen($this->path); - /** - * @var \OC\Files\Storage\Storage $storage - */ - list($storage, $internalPath) = $this->view->resolvePath($this->path); + $mount = $this->root->getMount($this->path); + $storage = $mount->getStorage(); + $internalPath = $mount->getInternalPath($this->path); $internalPath = rtrim($internalPath, '/'); if ($internalPath !== '') { $internalPath = $internalPath . '/'; @@ -229,7 +228,7 @@ class Folder extends Node implements \OCP\Files\Folder { $result['internalPath'] = $result['path']; $result['path'] = substr($result['path'], $internalRootLength); $result['storage'] = $storage; - $files[] = $result; + $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, $result['internalPath'], $result, $mount); } } @@ -245,17 +244,14 @@ class Folder extends Node implements \OCP\Files\Folder { $result['internalPath'] = $result['path']; $result['path'] = $relativeMountPoint . $result['path']; $result['storage'] = $storage; - $files[] = $result; + $files[] = new \OC\Files\FileInfo($this->path . '/' . $result['path'], $storage, $result['internalPath'], $result, $mount); } } } - $result = array(); - foreach ($files as $file) { - $result[] = $this->createNode($this->normalizePath($this->path . '/' . $file['path']), $file); - } - - return $result; + return array_map(function(FileInfo $file) { + return $this->createNode($file->getPath(), $file); + }, $files); } /** |