diff options
author | zeripath <art27@cantab.net> | 2022-03-21 08:09:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-21 09:09:42 +0100 |
commit | b05b40180f41b440d18a6d6abafd2d6187979bfe (patch) | |
tree | bbc90af80de79472111f255d8e174370169ff634 | |
parent | c604c9ae66696539174b04a33f9f3bb73b7a09c2 (diff) | |
download | gitea-b05b40180f41b440d18a6d6abafd2d6187979bfe.tar.gz gitea-b05b40180f41b440d18a6d6abafd2d6187979bfe.zip |
Use IterateBufferSize whilst querying repositories during adoption check (#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 <art27@cantab.net>
-rw-r--r-- | services/repository/adopt.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/services/repository/adopt.go b/services/repository/adopt.go index 72fe284ad3..2af01e973a 100644 --- a/services/repository/adopt.go +++ b/services/repository/adopt.go @@ -339,6 +339,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 |