aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/migrate.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/repo/migrate.go')
-rw-r--r--routers/web/repo/migrate.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go
index bbc349a0a5..b918650d1d 100644
--- a/routers/web/repo/migrate.go
+++ b/routers/web/repo/migrate.go
@@ -10,6 +10,7 @@ import (
"strings"
"code.gitea.io/gitea/models"
+ admin_model "code.gitea.io/gitea/models/admin"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@@ -257,3 +258,20 @@ func setMigrationContextData(ctx *context.Context, serviceType structs.GitServic
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
ctx.Data["service"] = serviceType
}
+
+func MigrateCancelPost(ctx *context.Context) {
+ migratingTask, err := admin_model.GetMigratingTask(ctx.Repo.Repository.ID)
+ if err != nil {
+ log.Error("GetMigratingTask: %v", err)
+ ctx.Redirect(ctx.Repo.Repository.Link())
+ return
+ }
+ if migratingTask.Status == structs.TaskStatusRunning {
+ taskUpdate := &admin_model.Task{ID: migratingTask.ID, Status: structs.TaskStatusFailed, Message: "canceled"}
+ if err = taskUpdate.UpdateCols("status", "message"); err != nil {
+ ctx.ServerError("task.UpdateCols", err)
+ return
+ }
+ }
+ ctx.Redirect(ctx.Repo.Repository.Link())
+}