diff --git a/apps/dav/lib/connector/sabre/directory.php b/apps/dav/lib/connector/sabre/directory.php index 59e2ef3d2e..0119879a17 100644 --- a/apps/dav/lib/connector/sabre/directory.php +++ b/apps/dav/lib/connector/sabre/directory.php @@ -53,6 +53,23 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node */ private $quotaInfo; + /** + * @var ObjectTree|null + */ + private $tree; + + /** + * Sets up the node, expects a full path name + * + * @param \OC\Files\View $view + * @param \OCP\Files\FileInfo $info + * @param ObjectTree|null $tree + */ + public function __construct($view, $info, $tree = null) { + parent::__construct($view, $info); + $this->tree = $tree; + } + /** * Creates a new file in the directory * @@ -185,10 +202,13 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node } if ($info['mimetype'] == 'httpd/unix-directory') { - $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info); + $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree); } else { $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info); } + if ($this->tree) { + $this->tree->cacheNode($node); + } return $node; } diff --git a/apps/dav/lib/connector/sabre/objecttree.php b/apps/dav/lib/connector/sabre/objecttree.php index 55b310a440..a1796136c4 100644 --- a/apps/dav/lib/connector/sabre/objecttree.php +++ b/apps/dav/lib/connector/sabre/objecttree.php @@ -94,6 +94,10 @@ class ObjectTree extends \Sabre\DAV\Tree { return $path; } + public function cacheNode(Node $node) { + $this->cache[trim($node->getPath(), '/')] = $node; + } + /** * Returns the INode object for the requested path * @@ -108,6 +112,11 @@ class ObjectTree extends \Sabre\DAV\Tree { } $path = trim($path, '/'); + + if (isset($this->cache[$path])) { + return $this->cache[$path]; + } + if ($path) { try { $this->fileView->verifyPath($path, basename($path)); @@ -116,10 +125,6 @@ class ObjectTree extends \Sabre\DAV\Tree { } } - if (isset($this->cache[$path])) { - return $this->cache[$path]; - } - // Is it the root node? if (!strlen($path)) { return $this->rootNode; @@ -162,7 +167,7 @@ class ObjectTree extends \Sabre\DAV\Tree { } if ($info->getType() === 'dir') { - $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info); + $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this); } else { $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info); } diff --git a/apps/dav/lib/connector/sabre/serverfactory.php b/apps/dav/lib/connector/sabre/serverfactory.php index 88e7e9a545..92038c1872 100644 --- a/apps/dav/lib/connector/sabre/serverfactory.php +++ b/apps/dav/lib/connector/sabre/serverfactory.php @@ -120,7 +120,7 @@ class ServerFactory { // Create ownCloud Dir if ($rootInfo->getType() === 'dir') { - $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo); + $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree); } else { $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo); }