diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-23 13:08:17 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-23 13:08:17 +0100 |
commit | ea07a428f463a866b2c5e44e243a33d8980c8850 (patch) | |
tree | 3183f2b62f74d0a139b086d4137a82d433b927ec /lib | |
parent | 7800b9dbc82dfcb6f1fe46f89a215d97afec071c (diff) | |
parent | 0b0b3253bb75f5fffb39201da39139d4f26d8a22 (diff) | |
download | nextcloud-server-ea07a428f463a866b2c5e44e243a33d8980c8850.tar.gz nextcloud-server-ea07a428f463a866b2c5e44e243a33d8980c8850.zip |
Merge pull request #22506 from owncloud/node-get-from-cache
Query the cache when checking if a node exists
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/node/folder.php | 32 | ||||
-rw-r--r-- | lib/private/files/node/root.php | 17 |
2 files changed, 23 insertions, 26 deletions
diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index e8c49cd2c0b..f4d7dae20a3 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -90,19 +90,19 @@ 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); + return new Folder($this->root, $this->view, $path, $info); } else { - return new File($this->root, $this->view, $path); + return new File($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); } /** diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index 0be7ee2c499..69c98368dfd 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -176,8 +176,9 @@ class Root extends Folder implements IRootFolder { $path = $this->normalizePath($path); if ($this->isValidPath($path)) { $fullPath = $this->getFullPath($path); - if ($this->view->file_exists($fullPath)) { - return $this->createNode($fullPath); + $fileInfo = $this->view->getFileInfo($fullPath); + if ($fileInfo) { + return $this->createNode($fullPath, $fileInfo); } else { throw new NotFoundException($path); } @@ -336,18 +337,18 @@ class Root extends Folder implements IRootFolder { $dir = '/' . $userId; $folder = null; - if (!$this->nodeExists($dir)) { - $folder = $this->newFolder($dir); - } else { + try { $folder = $this->get($dir); + } catch (NotFoundException $e) { + $folder = $this->newFolder($dir); } $dir = '/files'; - if (!$folder->nodeExists($dir)) { + try { + $folder = $folder->get($dir); + } catch (NotFoundException $e) { $folder = $folder->newFolder($dir); \OC_Util::copySkeleton($userId, $folder); - } else { - $folder = $folder->get($dir); } return $folder; |