diff options
Diffstat (limited to 'models/task.go')
-rw-r--r-- | models/task.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/models/task.go b/models/task.go index 5528573ca5..cabb96c608 100644 --- a/models/task.go +++ b/models/task.go @@ -5,6 +5,7 @@ package models import ( + "context" "fmt" "code.gitea.io/gitea/models/db" @@ -51,15 +52,15 @@ type TranslatableMessage struct { // LoadRepo loads repository of the task func (task *Task) LoadRepo() error { - return task.loadRepo(db.GetEngine(db.DefaultContext)) + return task.loadRepo(db.DefaultContext) } -func (task *Task) loadRepo(e db.Engine) error { +func (task *Task) loadRepo(ctx context.Context) error { if task.Repo != nil { return nil } var repo repo_model.Repository - has, err := e.ID(task.RepoID).Get(&repo) + has, err := db.GetEngine(ctx).ID(task.RepoID).Get(&repo) if err != nil { return err } else if !has { @@ -233,12 +234,7 @@ func FindTasks(opts FindTaskOptions) ([]*Task, error) { // CreateTask creates a task on database func CreateTask(task *Task) error { - return createTask(db.GetEngine(db.DefaultContext), task) -} - -func createTask(e db.Engine, task *Task) error { - _, err := e.Insert(task) - return err + return db.Insert(db.DefaultContext, task) } // FinishMigrateTask updates database when migrate task finished |