summaryrefslogtreecommitdiffstats
path: root/models/task.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/task.go')
-rw-r--r--models/task.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/models/task.go b/models/task.go
index 43cb2d4d9a..b86314b449 100644
--- a/models/task.go
+++ b/models/task.go
@@ -147,6 +147,27 @@ func GetMigratingTask(repoID int64) (*Task, error) {
return &task, nil
}
+// GetMigratingTaskByID returns the migrating task by repo's id
+func GetMigratingTaskByID(id, doerID int64) (*Task, *migration.MigrateOptions, error) {
+ var task = Task{
+ ID: id,
+ DoerID: doerID,
+ Type: structs.TaskTypeMigrateRepo,
+ }
+ has, err := x.Get(&task)
+ if err != nil {
+ return nil, nil, err
+ } else if !has {
+ return nil, nil, ErrTaskDoesNotExist{id, 0, task.Type}
+ }
+
+ var opts migration.MigrateOptions
+ if err := json.Unmarshal([]byte(task.PayloadContent), &opts); err != nil {
+ return nil, nil, err
+ }
+ return &task, &opts, nil
+}
+
// FindTaskOptions find all tasks
type FindTaskOptions struct {
Status int