Merge pull request #16433 from nextcloud/backport/16424/stable15

[stable15] Do not keep searching for recent
This commit is contained in:
Roeland Jago Douma 2019-07-17 09:20:53 +02:00 committed by GitHub
commit cb99a62c07
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);
}