Put nodes from Directory->getChildren in the ObjectTree cache

This commit is contained in:
Robin Appelman 2015-12-30 14:10:03 +01:00 committed by Roeland Jago Douma
parent 2095a31000
commit 97a2fb8a54
3 changed files with 32 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}