summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-06-16 23:02:24 +0100
committerGitHub <noreply@github.com>2021-06-16 18:02:24 -0400
commit6d69df28047bf7fd3e307391b484a93432615b90 (patch)
tree8a24ce0727f86625c4f469b6744f6f3f2fa27c86 /routers
parent047c39e91bb39d4f31278d8c4082187894ea8263 (diff)
downloadgitea-6d69df28047bf7fd3e307391b484a93432615b90.tar.gz
gitea-6d69df28047bf7fd3e307391b484a93432615b90.zip
Add Status Updates whilst Gitea migrations are occurring (#15076)
* Add migrating message Signed-off-by: Andrew Thornton <art27@cantab.net> * simplify messenger Signed-off-by: Andrew Thornton <art27@cantab.net> * make messenger an interface Signed-off-by: Andrew Thornton <art27@cantab.net> * rename Signed-off-by: Andrew Thornton <art27@cantab.net> * prepare for merge Signed-off-by: Andrew Thornton <art27@cantab.net> * as per tech Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/migrate.go2
-rw-r--r--routers/web/user/task.go18
2 files changed, 18 insertions, 2 deletions
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go
index 5307fdc7d9..de33a3645b 100644
--- a/routers/api/v1/repo/migrate.go
+++ b/routers/api/v1/repo/migrate.go
@@ -199,7 +199,7 @@ func Migrate(ctx *context.APIContext) {
}
}()
- if _, err = migrations.MigrateRepository(graceful.GetManager().HammerContext(), ctx.User, repoOwner.Name, opts); err != nil {
+ if _, err = migrations.MigrateRepository(graceful.GetManager().HammerContext(), ctx.User, repoOwner.Name, opts, nil); err != nil {
handleMigrateError(ctx, repoOwner, remoteAddr, err)
return
}
diff --git a/routers/web/user/task.go b/routers/web/user/task.go
index b8df5d99c7..8e7b66ef95 100644
--- a/routers/web/user/task.go
+++ b/routers/web/user/task.go
@@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
+ jsoniter "github.com/json-iterator/go"
)
// TaskStatus returns task's status
@@ -21,9 +22,24 @@ func TaskStatus(ctx *context.Context) {
return
}
+ message := task.Message
+
+ if task.Message != "" && task.Message[0] == '{' {
+ // assume message is actually a translatable string
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
+ var translatableMessage models.TranslatableMessage
+ if err := json.Unmarshal([]byte(message), &translatableMessage); err != nil {
+ translatableMessage = models.TranslatableMessage{
+ Format: "migrate.migrating_failed.error",
+ Args: []interface{}{task.Message},
+ }
+ }
+ message = ctx.Tr(translatableMessage.Format, translatableMessage.Args...)
+ }
+
ctx.JSON(http.StatusOK, map[string]interface{}{
"status": task.Status,
- "err": task.Errors,
+ "message": message,
"repo-id": task.RepoID,
"repo-name": opts.RepoName,
"start": task.StartTime,