diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-13 15:16:07 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-13 15:16:07 +0200 |
commit | 660aa7ff1e7bcb61d5dcb103014da39b8a257899 (patch) | |
tree | b16f04b41cc3b6308639b405336bc03e419c89ad /lib | |
parent | a88e013f722a2bf30100074760509613c76ca807 (diff) | |
parent | b717681e3ae5be70b1b897716201ddc2e631b172 (diff) | |
download | nextcloud-server-660aa7ff1e7bcb61d5dcb103014da39b8a257899.tar.gz nextcloud-server-660aa7ff1e7bcb61d5dcb103014da39b8a257899.zip |
Merge pull request #15568 from owncloud/cache_user_folder_for_file_search_results
cach user folder for file search results
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/search/result/file.php | 13 |
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); } } |