mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 01:00:50 -04:00
Merge pull request #15568 from owncloud/cache_user_folder_for_file_search_results
cach user folder for file search results
This commit is contained in:
commit
660aa7ff1e
1 changed files with 11 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue