summaryrefslogtreecommitdiffstats
path: root/modules/doctor
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-11-19 09:12:33 +0100
committerGitHub <noreply@github.com>2022-11-19 16:12:33 +0800
commit044c754ea53f5b81f451451df53aea366f6f700a (patch)
tree45688c28a84f87f71ec3f99eb0e8456eb7d19c42 /modules/doctor
parentfefdb7ffd11bbfbff66dae8e88681ec840dedfde (diff)
downloadgitea-044c754ea53f5b81f451451df53aea366f6f700a.tar.gz
gitea-044c754ea53f5b81f451451df53aea366f6f700a.zip
Add `context.Context` to more methods (#21546)
This PR adds a context parameter to a bunch of methods. Some helper `xxxCtx()` methods got replaced with the normal name now. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/doctor')
-rw-r--r--modules/doctor/dbconsistency.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/modules/doctor/dbconsistency.go b/modules/doctor/dbconsistency.go
index 89d974a350..602b2e523e 100644
--- a/modules/doctor/dbconsistency.go
+++ b/modules/doctor/dbconsistency.go
@@ -18,13 +18,13 @@ import (
type consistencyCheck struct {
Name string
- Counter func() (int64, error)
- Fixer func() (int64, error)
+ Counter func(context.Context) (int64, error)
+ Fixer func(context.Context) (int64, error)
FixedMessage string
}
func (c *consistencyCheck) Run(ctx context.Context, logger log.Logger, autofix bool) error {
- count, err := c.Counter()
+ count, err := c.Counter(ctx)
if err != nil {
logger.Critical("Error: %v whilst counting %s", err, c.Name)
return err
@@ -32,7 +32,7 @@ func (c *consistencyCheck) Run(ctx context.Context, logger log.Logger, autofix b
if count > 0 {
if autofix {
var fixed int64
- if fixed, err = c.Fixer(); err != nil {
+ if fixed, err = c.Fixer(ctx); err != nil {
logger.Critical("Error: %v whilst fixing %s", err, c.Name)
return err
}
@@ -54,9 +54,9 @@ func (c *consistencyCheck) Run(ctx context.Context, logger log.Logger, autofix b
return nil
}
-func asFixer(fn func() error) func() (int64, error) {
- return func() (int64, error) {
- err := fn()
+func asFixer(fn func(ctx context.Context) error) func(ctx context.Context) (int64, error) {
+ return func(ctx context.Context) (int64, error) {
+ err := fn(ctx)
return -1, err
}
}
@@ -64,11 +64,11 @@ func asFixer(fn func() error) func() (int64, error) {
func genericOrphanCheck(name, subject, refobject, joincond string) consistencyCheck {
return consistencyCheck{
Name: name,
- Counter: func() (int64, error) {
- return db.CountOrphanedObjects(subject, refobject, joincond)
+ Counter: func(ctx context.Context) (int64, error) {
+ return db.CountOrphanedObjects(ctx, subject, refobject, joincond)
},
- Fixer: func() (int64, error) {
- err := db.DeleteOrphanedObjects(subject, refobject, joincond)
+ Fixer: func(ctx context.Context) (int64, error) {
+ err := db.DeleteOrphanedObjects(ctx, subject, refobject, joincond)
return -1, err
},
}