Skip to content

Commit 23b8214

Browse files
authored
Use IterateBufferSize whilst querying repositories during adoption check (go-gitea#19140) (go-gitea#19160)
Backport go-gitea#19140 The adoption page checks directories to see if they are repositories by querying the db on a per user basis. This can lead to problems if a user has a large number of repositories or putative repositories. This PR changes the buffering to check the db in IterataeBufferSize batches instead. Fix go-gitea#19137 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 08feb6b commit 23b8214

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

services/repository/adopt.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ func ListUnadoptedRepositories(query string, opts *db.ListOptions) ([]string, in
335335
}
336336

337337
repoNamesToCheck = append(repoNamesToCheck, name)
338+
if len(repoNamesToCheck) > setting.Database.IterateBufferSize {
339+
if err = checkUnadoptedRepositories(userName, repoNamesToCheck, unadopted); err != nil {
340+
return err
341+
}
342+
repoNamesToCheck = repoNamesToCheck[:0]
343+
344+
}
338345
return filepath.SkipDir
339346
}); err != nil {
340347
return nil, 0, err

0 commit comments

Comments
 (0)