Merge pull request #22797 from nextcloud/fix/search/files
Fix files search provider
This commit is contained in:
commit
a68e23a536
|
@ -31,6 +31,7 @@ namespace OCA\Files\Search;
|
||||||
use OC\Search\Provider\File;
|
use OC\Search\Provider\File;
|
||||||
use OC\Search\Result\File as FileResult;
|
use OC\Search\Result\File as FileResult;
|
||||||
use OCP\Files\IMimeTypeDetector;
|
use OCP\Files\IMimeTypeDetector;
|
||||||
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
|
@ -53,14 +54,19 @@ class FilesSearchProvider implements IProvider {
|
||||||
/** @var IMimeTypeDetector */
|
/** @var IMimeTypeDetector */
|
||||||
private $mimeTypeDetector;
|
private $mimeTypeDetector;
|
||||||
|
|
||||||
|
/** @var IRootFolder */
|
||||||
|
private $rootFolder;
|
||||||
|
|
||||||
public function __construct(File $fileSearch,
|
public function __construct(File $fileSearch,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
IURLGenerator $urlGenerator,
|
IURLGenerator $urlGenerator,
|
||||||
IMimeTypeDetector $mimeTypeDetector) {
|
IMimeTypeDetector $mimeTypeDetector,
|
||||||
|
IRootFolder $rootFolder) {
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->fileSearch = $fileSearch;
|
$this->fileSearch = $fileSearch;
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
$this->mimeTypeDetector = $mimeTypeDetector;
|
$this->mimeTypeDetector = $mimeTypeDetector;
|
||||||
|
$this->rootFolder = $rootFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,6 +98,10 @@ class FilesSearchProvider implements IProvider {
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function search(IUser $user, ISearchQuery $query): SearchResult {
|
public function search(IUser $user, ISearchQuery $query): SearchResult {
|
||||||
|
|
||||||
|
// Make sure we setup the users filesystem
|
||||||
|
$this->rootFolder->getUserFolder($user->getUID());
|
||||||
|
|
||||||
return SearchResult::complete(
|
return SearchResult::complete(
|
||||||
$this->l10n->t('Files'),
|
$this->l10n->t('Files'),
|
||||||
array_map(function (FileResult $result) {
|
array_map(function (FileResult $result) {
|
||||||
|
|
Loading…
Reference in New Issue