diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /services/cron/tasks.go | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip |
Move user related model into models/user (#17781)
* Move user related model into models/user
* Fix lint for windows
* Fix windows lint
* Fix windows lint
* Move some tests in models
* Merge
Diffstat (limited to 'services/cron/tasks.go')
-rw-r--r-- | services/cron/tasks.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/services/cron/tasks.go b/services/cron/tasks.go index 732eead930..75bb4993c0 100644 --- a/services/cron/tasks.go +++ b/services/cron/tasks.go @@ -10,9 +10,9 @@ import ( "reflect" "sync" - "code.gitea.io/gitea/models" admin_model "code.gitea.io/gitea/models/admin" "code.gitea.io/gitea/models/db" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -29,7 +29,7 @@ type Task struct { lock sync.Mutex Name string config Config - fun func(context.Context, *models.User, Config) error + fun func(context.Context, *user_model.User, Config) error ExecTimes int64 } @@ -55,7 +55,7 @@ func (t *Task) GetConfig() Config { // Run will run the task incrementing the cron counter with no user defined func (t *Task) Run() { - t.RunWithUser(&models.User{ + t.RunWithUser(&user_model.User{ ID: -1, Name: "(Cron)", LowerName: "(cron)", @@ -63,7 +63,7 @@ func (t *Task) Run() { } // RunWithUser will run the task incrementing the cron counter at the time with User -func (t *Task) RunWithUser(doer *models.User, config Config) { +func (t *Task) RunWithUser(doer *user_model.User, config Config) { if !taskStatusTable.StartIfNotRunning(t.Name) { return } @@ -118,7 +118,7 @@ func GetTask(name string) *Task { } // RegisterTask allows a task to be registered with the cron service -func RegisterTask(name string, config Config, fun func(context.Context, *models.User, Config) error) error { +func RegisterTask(name string, config Config, fun func(context.Context, *user_model.User, Config) error) error { log.Debug("Registering task: %s", name) _, err := setting.GetCronSettings(name, config) if err != nil { @@ -163,7 +163,7 @@ func RegisterTask(name string, config Config, fun func(context.Context, *models. } // RegisterTaskFatal will register a task but if there is an error log.Fatal -func RegisterTaskFatal(name string, config Config, fun func(context.Context, *models.User, Config) error) { +func RegisterTaskFatal(name string, config Config, fun func(context.Context, *user_model.User, Config) error) { if err := RegisterTask(name, config, fun); err != nil { log.Fatal("Unable to register cron task %s Error: %v", name, err) } |