Skip to content

Commit cb99a62

Browse files
authored
Merge pull request #16433 from nextcloud/backport/16424/stable15
[stable15] Do not keep searching for recent
2 parents f42afb0 + 7bd081f commit cb99a62

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/private/Files/Node/Folder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ public function getRecent($limit, $offset = 0) {
383383
// Search in batches of 500 entries
384384
$searchLimit = 500;
385385
$results = [];
386+
$searchResultCount = 0;
387+
$count = 0;
386388
do {
387389
$searchResult = $this->recentSearch($searchLimit, $offset, $storageIds, $folderMimetype);
388390

@@ -391,14 +393,17 @@ public function getRecent($limit, $offset = 0) {
391393
break;
392394
}
393395

396+
$searchResultCount += count($searchResult);
397+
394398
$parseResult = $this->recentParse($searchResult, $mountMap, $mimetypeLoader);
395399

396400
foreach ($parseResult as $result) {
397401
$results[] = $result;
398402
}
399403

400404
$offset += $searchLimit;
401-
} while (count($results) < $limit);
405+
$count++;
406+
} while (count($results) < $limit && ($searchResultCount < (3 * $limit) || $count < 5));
402407

403408
return array_slice($results, 0, $limit);
404409
}

0 commit comments

Comments
 (0)