summaryrefslogtreecommitdiffstats
path: root/lib/private/search
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2015-04-13 11:29:10 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2015-04-13 11:29:10 +0200
commitb717681e3ae5be70b1b897716201ddc2e631b172 (patch)
treefbd64eabebffb50d904d511543daa168a05ffa08 /lib/private/search
parentc3fbc2b6fd09bb5b94112da9248cae28d6ef85e3 (diff)
downloadnextcloud-server-b717681e3ae5be70b1b897716201ddc2e631b172.tar.gz
nextcloud-server-b717681e3ae5be70b1b897716201ddc2e631b172.zip
cach user folder for file search results
Diffstat (limited to 'lib/private/search')
-rw-r--r--lib/private/search/result/file.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/search/result/file.php b/lib/private/search/result/file.php
index be9c34b6e48..50b74e1ced2 100644
--- a/lib/private/search/result/file.php
+++ b/lib/private/search/result/file.php
@@ -25,6 +25,7 @@
namespace OC\Search\Result;
use OC\Files\Filesystem;
use OCP\Files\FileInfo;
+use OCP\Files\Folder;
/**
* A found file
@@ -92,14 +93,22 @@ class File extends \OCP\Search\Result {
}
/**
+ * @var Folder $userFolderCache
+ */
+ static protected $userFolderCache = null;
+
+ /**
* converts a path relative to the users files folder
* eg /user/files/foo.txt -> /foo.txt
* @param string $path
* @return string relative path
*/
protected function getRelativePath ($path) {
- $root = \OC::$server->getUserFolder();
- return $root->getRelativePath($path);
+ if (!isset(self::$userFolderCache)) {
+ $user = \OC::$server->getUserSession()->getUser()->getUID();
+ self::$userFolderCache = \OC::$server->getUserFolder($user);
+ }
+ return self::$userFolderCache->getRelativePath($path);
}
}