diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/task/task.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/services/task/task.go b/services/task/task.go index 11a47a68bb..db5c1dd3f8 100644 --- a/services/task/task.go +++ b/services/task/task.go @@ -126,3 +126,27 @@ func CreateMigrateTask(doer, u *user_model.User, opts base.MigrateOptions) (*adm return task, nil } + +// RetryMigrateTask retry a migrate task +func RetryMigrateTask(repoID int64) error { + migratingTask, err := admin_model.GetMigratingTask(repoID) + if err != nil { + log.Error("GetMigratingTask: %v", err) + return err + } + if migratingTask.Status == structs.TaskStatusQueued || migratingTask.Status == structs.TaskStatusRunning { + return nil + } + + // TODO Need to removing the storage/database garbage brought by the failed task + + // Reset task status and messages + migratingTask.Status = structs.TaskStatusQueued + migratingTask.Message = "" + if err = migratingTask.UpdateCols("status", "message"); err != nil { + log.Error("task.UpdateCols failed: %v", err) + return err + } + + return taskQueue.Push(migratingTask) +} |