diff options
-rw-r--r-- | apps/files/lib/Search/FilesSearchProvider.php | 5 | ||||
-rw-r--r-- | lib/private/Search/Provider/File.php | 22 |
2 files changed, 23 insertions, 4 deletions
diff --git a/apps/files/lib/Search/FilesSearchProvider.php b/apps/files/lib/Search/FilesSearchProvider.php index 93600119357..1c4bc75ade7 100644 --- a/apps/files/lib/Search/FilesSearchProvider.php +++ b/apps/files/lib/Search/FilesSearchProvider.php @@ -103,7 +103,7 @@ class FilesSearchProvider implements IProvider { // Make sure we setup the users filesystem $this->rootFolder->getUserFolder($user->getUID()); - return SearchResult::complete( + return SearchResult::paginated( $this->l10n->t('Files'), array_map(function (FileResult $result) { // Generate thumbnail url @@ -121,7 +121,8 @@ class FilesSearchProvider implements IProvider { $searchResultEntry->addAttribute('fileId', (string)$result->id); $searchResultEntry->addAttribute('path', $result->path); return $searchResultEntry; - }, $this->fileSearch->search($query->getTerm())) + }, $this->fileSearch->search($query->getTerm(), $query->getLimit(), (int)$query->getCursor())), + $query->getCursor() + $query->getLimit() ); } diff --git a/lib/private/Search/Provider/File.php b/lib/private/Search/Provider/File.php index b4e35d374ca..4125b1f7d70 100644 --- a/lib/private/Search/Provider/File.php +++ b/lib/private/Search/Provider/File.php @@ -30,23 +30,33 @@ namespace OC\Search\Provider; use OC\Files\Filesystem; +use OCP\Search\PagedProvider; /** * Provide search results from the 'files' app * @deprecated 20.0.0 */ -class File extends \OCP\Search\Provider { +class File extends PagedProvider { /** * Search for files and folders matching the given query + * * @param string $query + * @param int|null $limit + * @param int|null $offset * @return \OCP\Search\Result[] * @deprecated 20.0.0 */ - public function search($query) { + public function search($query, int $limit = null, int $offset = null) { + if ($offset === null) { + $offset = 0; + } \OC_Util::setupFS(); $files = Filesystem::search($query); $results = []; + if ($limit !== null) { + $files = array_slice($files, $offset, $offset + $limit); + } // edit results foreach ($files as $fileData) { // skip versions @@ -79,4 +89,12 @@ class File extends \OCP\Search\Provider { // return return $results; } + + public function searchPaged($query, $page, $size) { + if ($size === 0) { + return $this->search($query); + } else { + return $this->search($query, $size, ($page - 1) * $size); + } + } } |