Merge pull request #16424 from nextcloud/fix/do_not_keep_searching

Do not keep searching for recent
This commit is contained in:
Roeland Jago Douma 2019-07-17 07:46:47 +02:00 committed by GitHub
commit 4a52d933b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -383,6 +383,8 @@ class Folder extends Node implements \OCP\Files\Folder {
// Search in batches of 500 entries
$searchLimit = 500;
$results = [];
$searchResultCount = 0;
$count = 0;
do {
$searchResult = $this->recentSearch($searchLimit, $offset, $storageIds, $folderMimetype);
@ -391,6 +393,8 @@ class Folder extends Node implements \OCP\Files\Folder {
break;
}
$searchResultCount += count($searchResult);
$parseResult = $this->recentParse($searchResult, $mountMap, $mimetypeLoader);
foreach ($parseResult as $result) {
@ -398,7 +402,8 @@ class Folder extends Node implements \OCP\Files\Folder {
}
$offset += $searchLimit;
} while (count($results) < $limit);
$count++;
} while (count($results) < $limit && ($searchResultCount < (3 * $limit) || $count < 5));
return array_slice($results, 0, $limit);
}