Skip to content
Snippets Groups Projects
Commit 660aa7ff authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #15568 from owncloud/cache_user_folder_for_file_search_results

cach user folder for file search results
parents a88e013f b717681e
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@
namespace OC\Search\Result;
use OC\Files\Filesystem;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
/**
* A found file
......@@ -91,6 +92,11 @@ class File extends \OCP\Search\Result {
$this->mime = $data->getMimetype();
}
/**
* @var Folder $userFolderCache
*/
static protected $userFolderCache = null;
/**
* converts a path relative to the users files folder
* eg /user/files/foo.txt -> /foo.txt
......@@ -98,8 +104,11 @@ class File extends \OCP\Search\Result {
* @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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment