aboutsummaryrefslogtreecommitdiffstats
path: root/services
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
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')
-rw-r--r--services/repository/avatar.go2
-rw-r--r--services/repository/check.go12
-rw-r--r--services/repository/hooks.go4
3 files changed, 5 insertions, 13 deletions
diff --git a/services/repository/avatar.go b/services/repository/avatar.go
index b80a8fb775..1cf9e869c0 100644
--- a/services/repository/avatar.go
+++ b/services/repository/avatar.go
@@ -96,7 +96,7 @@ func DeleteAvatar(repo *repo_model.Repository) error {
// RemoveRandomAvatars removes the randomly generated avatars that were created for repositories
func RemoveRandomAvatars(ctx context.Context) error {
- return db.IterateObjects(ctx, func(repository *repo_model.Repository) error {
+ return db.Iterate(ctx, nil, func(ctx context.Context, repository *repo_model.Repository) error {
select {
case <-ctx.Done():
return db.ErrCancelledf("before random avatars removed for %s", repository.FullName())
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())
diff --git a/services/repository/hooks.go b/services/repository/hooks.go
index d326cd26b1..d29384e012 100644
--- a/services/repository/hooks.go
+++ b/services/repository/hooks.go
@@ -25,10 +25,8 @@ func SyncRepositoryHooks(ctx context.Context) error {
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 sync repository hooks for %s", repo.FullName())