From 534551e736ba788edbe74d3e3fe92e3a48d363e1 Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 21 Mar 2022 08:09:42 +0000 Subject: [PATCH] Use IterateBufferSize whilst querying repositories during adoption check (#19140) Backport #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 #19137 Signed-off-by: Andrew Thornton --- services/repository/adopt.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/repository/adopt.go b/services/repository/adopt.go index fc3fdc608fd93..d91e6a20e6129 100644 --- a/services/repository/adopt.go +++ b/services/repository/adopt.go @@ -335,6 +335,13 @@ func ListUnadoptedRepositories(query string, opts *db.ListOptions) ([]string, in } repoNamesToCheck = append(repoNamesToCheck, name) + if len(repoNamesToCheck) > setting.Database.IterateBufferSize { + if err = checkUnadoptedRepositories(userName, repoNamesToCheck, unadopted); err != nil { + return err + } + repoNamesToCheck = repoNamesToCheck[:0] + + } return filepath.SkipDir }); err != nil { return nil, 0, err