Skip to content

Commit

Permalink
Use IterateBufferSize whilst querying repositories during adoption ch…
Browse files Browse the repository at this point in the history
…eck (#19140) (#19160)

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 <art27@cantab.net>
  • Loading branch information
zeripath committed Mar 22, 2022
1 parent 08feb6b commit 23b8214
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/repository/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23b8214

Please sign in to comment.