summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-12-30 14:10:03 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-17 09:33:05 +0100
commit97a2fb8a5425a0d1e935da28b1e5dc9981513584 (patch)
treeba45ae6e8938704919eb26f1dd06a161cb023a46
parent2095a310009b47826efa8281908d946bb4c50a0b (diff)
downloadnextcloud-server-97a2fb8a5425a0d1e935da28b1e5dc9981513584.tar.gz
nextcloud-server-97a2fb8a5425a0d1e935da28b1e5dc9981513584.zip
Put nodes from Directory->getChildren in the ObjectTree cache
-rw-r--r--apps/dav/lib/connector/sabre/directory.php22
-rw-r--r--apps/dav/lib/connector/sabre/objecttree.php15
-rw-r--r--apps/dav/lib/connector/sabre/serverfactory.php2
3 files changed, 32 insertions, 7 deletions
diff --git a/apps/dav/lib/connector/sabre/directory.php b/apps/dav/lib/connector/sabre/directory.php
index 59e2ef3d2ec..0119879a171 100644
--- a/apps/dav/lib/connector/sabre/directory.php
+++ b/apps/dav/lib/connector/sabre/directory.php
@@ -54,6 +54,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
*
* Data will either be supplied as a stream resource, or in certain cases
@@ -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 55b310a4405..a1796136c4e 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 88e7e9a545f..92038c18724 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);
}