diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-03-22 23:22:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 16:22:54 +0100 |
commit | 7a550b3af20dad94cf468012a6b817b43b91c1ba (patch) | |
tree | 1b836eabf8e911f35d0446c0cdad053cb3572c79 /services/repository | |
parent | 2b55422cd71b0b325f054646de5cebf39b72b502 (diff) | |
download | gitea-7a550b3af20dad94cf468012a6b817b43b91c1ba.tar.gz gitea-7a550b3af20dad94cf468012a6b817b43b91c1ba.zip |
Use `ctx` instead of `db.DefaultContext` in some packages(routers/services/modules) (#19163)
* Remove `db.DefaultContext` usage in routers, use `ctx` directly
* Use `ctx` directly if there is one, remove some `db.DefaultContext` in `services`
* Use ctx instead of db.DefaultContext for `cmd` and some `modules` packages
* fix incorrect context usage
Diffstat (limited to 'services/repository')
-rw-r--r-- | services/repository/check.go | 8 | ||||
-rw-r--r-- | services/repository/hooks.go | 2 | ||||
-rw-r--r-- | services/repository/push.go | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/services/repository/check.go b/services/repository/check.go index 6adb8479c4..6962090f84 100644 --- a/services/repository/check.go +++ b/services/repository/check.go @@ -27,7 +27,7 @@ func GitFsck(ctx context.Context, timeout time.Duration, args []string) error { log.Trace("Doing: GitFsck") if err := db.Iterate( - db.DefaultContext, + ctx, new(repo_model.Repository), builder.Expr("id>0 AND is_fsck_enabled=?", true), func(idx int, bean interface{}) error { @@ -62,7 +62,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro args = append([]string{"gc"}, args...) if err := db.Iterate( - db.DefaultContext, + ctx, new(repo_model.Repository), builder.Gt{"id": 0}, func(idx int, bean interface{}) error { @@ -97,7 +97,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro } // Now update the size of the repository - if err := models.UpdateRepoSize(db.DefaultContext, repo); err != nil { + if err := models.UpdateRepoSize(ctx, repo); err != nil { log.Error("Updating size as part of garbage collection failed for %v. Stdout: %s\nError: %v", repo, stdout, err) desc := fmt.Sprintf("Updating size as part of garbage collection failed for %s. Stdout: %s\nError: %v", repo.RepoPath(), stdout, err) if err = admin_model.CreateRepositoryNotice(desc); err != nil { @@ -119,7 +119,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro func gatherMissingRepoRecords(ctx context.Context) ([]*repo_model.Repository, error) { repos := make([]*repo_model.Repository, 0, 10) if err := db.Iterate( - db.DefaultContext, + ctx, new(repo_model.Repository), builder.Gt{"id": 0}, func(idx int, bean interface{}) error { diff --git a/services/repository/hooks.go b/services/repository/hooks.go index 3905249499..40303d5937 100644 --- a/services/repository/hooks.go +++ b/services/repository/hooks.go @@ -23,7 +23,7 @@ func SyncRepositoryHooks(ctx context.Context) error { log.Trace("Doing: SyncRepositoryHooks") if err := db.Iterate( - db.DefaultContext, + ctx, new(repo_model.Repository), builder.Gt{"id": 0}, func(idx int, bean interface{}) error { diff --git a/services/repository/push.go b/services/repository/push.go index fafe4736ab..6cdfa1b4c2 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -95,7 +95,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { } defer gitRepo.Close() - if err = models.UpdateRepoSize(db.DefaultContext, repo); err != nil { + if err = models.UpdateRepoSize(ctx, repo); err != nil { log.Error("Failed to update size for repository: %v", err) } |