]> source.dussan.org Git - gitea.git/commitdiff
Do not list active repositories as unadopted (#22034) (#22167)
authorChristian Ullrich <chris@chrullrich.net>
Mon, 19 Dec 2022 12:48:57 +0000 (13:48 +0100)
committerGitHub <noreply@github.com>
Mon, 19 Dec 2022 12:48:57 +0000 (12:48 +0000)
Backport #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.

Co-authored-by: Christian Ullrich <christian.ullrich@traditionsa.lu>
services/repository/adopt.go

index 0df0aa049b136e9c322e9e286e6f8f27cf0d8a1d..46050cc5e41d76c57bd3184d37b4c88f6de52228 100644 (file)
@@ -340,7 +340,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
                        }