diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-09-06 10:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 10:16:01 +0200 |
commit | 1724fed8c530b0620aa97266b70d236fd8f38102 (patch) | |
tree | 1dd0e61d68dacc6146aeccfb13c741457f6019c1 /apps/dav/lib/Connector | |
parent | 9d930210eec9e30bbc1fcd3e154d65eb0fc7ae28 (diff) | |
parent | 42915b1e8bea013153834ff5ec4aa57b7b2908a9 (diff) | |
download | nextcloud-server-1724fed8c530b0620aa97266b70d236fd8f38102.tar.gz nextcloud-server-1724fed8c530b0620aa97266b70d236fd8f38102.zip |
Merge pull request #5415 from nextcloud/search-cache-node
cache nodes from search results
Diffstat (limited to 'apps/dav/lib/Connector')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/CachingTree.php | 39 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/ObjectTree.php | 6 | ||||
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Server.php | 1 |
3 files changed, 41 insertions, 5 deletions
diff --git a/apps/dav/lib/Connector/Sabre/CachingTree.php b/apps/dav/lib/Connector/Sabre/CachingTree.php new file mode 100644 index 00000000000..80c8311fed3 --- /dev/null +++ b/apps/dav/lib/Connector/Sabre/CachingTree.php @@ -0,0 +1,39 @@ +<?php +/** + * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\DAV\Connector\Sabre; + +use Sabre\DAV\Tree; + +class CachingTree extends Tree { + /** + * Store a node in the cache + * + * @param Node $node + * @param null|string $path + */ + public function cacheNode(Node $node, $path = null) { + if (is_null($path)) { + $path = $node->getPath(); + } + $this->cache[trim($path, '/')] = $node; + } +} diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php index 3371c655f29..a44b25c24cb 100644 --- a/apps/dav/lib/Connector/Sabre/ObjectTree.php +++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php @@ -39,7 +39,7 @@ use OCP\Files\StorageInvalidException; use OCP\Files\StorageNotAvailableException; use OCP\Lock\LockedException; -class ObjectTree extends \Sabre\DAV\Tree { +class ObjectTree extends CachingTree { /** * @var \OC\Files\View @@ -97,10 +97,6 @@ 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 * diff --git a/apps/dav/lib/Connector/Sabre/Server.php b/apps/dav/lib/Connector/Sabre/Server.php index 9915ffdba03..686b0ea7604 100644 --- a/apps/dav/lib/Connector/Sabre/Server.php +++ b/apps/dav/lib/Connector/Sabre/Server.php @@ -33,6 +33,7 @@ namespace OCA\DAV\Connector\Sabre; * @see \Sabre\DAV\Server */ class Server extends \Sabre\DAV\Server { + /** @var CachingTree $tree */ /** * @see \Sabre\DAV\Server |