aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
authorChristian Ullrich <chris@chrullrich.net>2022-12-16 09:58:56 +0100
committerGitHub <noreply@github.com>2022-12-16 16:58:56 +0800
commit84285a1169787c54ec2c583af83bcfb9182f00fa (patch)
treec705c660f4f8addd78c3dedd48319f6c3855f5a0 /services/repository
parent651fe4bb7dda16dee48b31ee964493a05e979c78 (diff)
downloadgitea-84285a1169787c54ec2c583af83bcfb9182f00fa.tar.gz
gitea-84285a1169787c54ec2c583af83bcfb9182f00fa.zip
Do not list active repositories as unadopted (#22034)
This fixes a bug where, when searching unadopted repositories, active repositories will be listed as well. This is because the size of the array of repository names to check is larger by one than the `IterateBufferSize`. For an `IterateBufferSize` of 50, the original code will pass 51 repository names but set the query to `LIMIT 50`. If all repositories in the query are active (i.e. not unadopted) one of them will be omitted from the result. Due to the `ORDER BY` clause it will be the oldest (or least recently modified) one. Bug found in 1.17.3. Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/adopt.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/services/repository/adopt.go b/services/repository/adopt.go
index 828068e8ec..93eeb56456 100644
--- a/services/repository/adopt.go
+++ b/services/repository/adopt.go
@@ -337,7 +337,7 @@ func ListUnadoptedRepositories(query string, opts *db.ListOptions) ([]string, in
}
repoNamesToCheck = append(repoNamesToCheck, name)
- if len(repoNamesToCheck) > setting.Database.IterateBufferSize {
+ if len(repoNamesToCheck) >= setting.Database.IterateBufferSize {
if err = checkUnadoptedRepositories(userName, repoNamesToCheck, unadopted); err != nil {
return err
}