aboutsummaryrefslogtreecommitdiffstats
path: root/services/repository/check.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-10-31 23:51:14 +0800
committerGitHub <noreply@github.com>2022-10-31 23:51:14 +0800
commit9a70a12a341b8e7773efc661693e4b7e3199a4bd (patch)
tree2e4f3e18315ef52e68d4bfea5939d5517d3ca56b /services/repository/check.go
parent4ae3f762177a2cdb449b949501420e88462f8f95 (diff)
downloadgitea-9a70a12a341b8e7773efc661693e4b7e3199a4bd.tar.gz
gitea-9a70a12a341b8e7773efc661693e4b7e3199a4bd.zip
Merge db.Iterate and IterateObjects (#21641)
These two functions are similiar, merge them.
Diffstat (limited to 'services/repository/check.go')
-rw-r--r--services/repository/check.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/services/repository/check.go b/services/repository/check.go
index 5529a61b39..5725f540b0 100644
--- a/services/repository/check.go
+++ b/services/repository/check.go
@@ -29,10 +29,8 @@ func GitFsck(ctx context.Context, timeout time.Duration, args []git.CmdArg) erro
if err := db.Iterate(
ctx,
- new(repo_model.Repository),
builder.Expr("id>0 AND is_fsck_enabled=?", true),
- func(idx int, bean interface{}) error {
- repo := bean.(*repo_model.Repository)
+ func(ctx context.Context, repo *repo_model.Repository) error {
select {
case <-ctx.Done():
return db.ErrCancelledf("before fsck of %s", repo.FullName())
@@ -64,10 +62,8 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...git.CmdArg)
if err := db.Iterate(
ctx,
- new(repo_model.Repository),
builder.Gt{"id": 0},
- func(idx int, bean interface{}) error {
- repo := bean.(*repo_model.Repository)
+ func(ctx context.Context, repo *repo_model.Repository) error {
select {
case <-ctx.Done():
return db.ErrCancelledf("before GC of %s", repo.FullName())
@@ -113,10 +109,8 @@ func gatherMissingRepoRecords(ctx context.Context) ([]*repo_model.Repository, er
repos := make([]*repo_model.Repository, 0, 10)
if err := db.Iterate(
ctx,
- new(repo_model.Repository),
builder.Gt{"id": 0},
- func(idx int, bean interface{}) error {
- repo := bean.(*repo_model.Repository)
+ func(ctx context.Context, repo *repo_model.Repository) error {
select {
case <-ctx.Done():
return db.ErrCancelledf("during gathering missing repo records before checking %s", repo.FullName())