Skip to content

Commit dd05549

Browse files
zeripathStelios Malathouras
authored andcommitted
Use IterateBufferSize whilst querying repositories during adoption check (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 817c8e3 commit dd05549

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
@@ -339,6 +339,13 @@ func ListUnadoptedRepositories(query string, opts *db.ListOptions) ([]string, in
339339
}
340340

341341
repoNamesToCheck = append(repoNamesToCheck, name)
342+
if len(repoNamesToCheck) > setting.Database.IterateBufferSize {
343+
if err = checkUnadoptedRepositories(userName, repoNamesToCheck, unadopted); err != nil {
344+
return err
345+
}
346+
repoNamesToCheck = repoNamesToCheck[:0]
347+
348+
}
342349
return filepath.SkipDir
343350
}); err != nil {
344351
return nil, 0, err

0 commit comments

Comments
 (0)