1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

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
This commit is contained in:
wxiaoguang
2022-03-22 23:22:54 +08:00
committed by GitHub
parent 2b55422cd7
commit 7a550b3af2
51 changed files with 117 additions and 124 deletions

View File

@@ -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 {