aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKerwin Bryant <kerwin612@qq.com>2023-08-04 10:21:32 +0800
committerGitHub <noreply@github.com>2023-08-04 10:21:32 +0800
commit865d2221c0f4b2a8623ff9299930c9bab0da2c78 (patch)
treed399ccbbee5a91be67f9d955e1f2845c9341cf76 /services
parent907bedaad0301730ee2fbab1f18b54b155dad088 (diff)
downloadgitea-865d2221c0f4b2a8623ff9299930c9bab0da2c78.tar.gz
gitea-865d2221c0f4b2a8623ff9299930c9bab0da2c78.zip
Add `Retry` button when creating a mirror-repo fails (#26228)
fixed #26156 * Added a retry button in the frontend (only displayed when the status is abnormal) * After clicking Retry, the backend adds the task back to the task queue ![7UJDNM671RI})EA8~~XPL39](https://github.com/go-gitea/gitea/assets/3371163/e088fd63-5dcc-4bc6-8849-7db3086511b7) ![T83F1WL9)VGHR@MB956$VT9](https://github.com/go-gitea/gitea/assets/3371163/744425bb-dde1-4315-be2e-5c99ac3a44d4) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services')
-rw-r--r--services/task/task.go24
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)
+}