cach user folder for file search results
This commit is contained in:
parent
c3fbc2b6fd
commit
b717681e3a
|
@ -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 New Issue