1
0

fix(migration): make sure to correctly check if a migration was already running

This change fixes a bug where Vikunja would not correctly check if a migration was already running. That meant it was not possible for users who had never before migrated anything to start a migration, because Vikunja assumed they already had a migration running for them.
This state was neither properly reflected in the frontend, which is now fixed as well.
This commit is contained in:
kolaente
2024-02-13 22:21:59 +01:00
parent a12c169ce8
commit 205f330f8a
2 changed files with 15 additions and 14 deletions

View File

@ -73,8 +73,8 @@ func (mw *MigrationWeb) Migrate(c echo.Context) error {
return handler.HandleHTTPError(err, c)
}
if stats.FinishedAt.IsZero() {
return c.JSON(http.StatusOK, map[string]string{
if !stats.StartedAt.IsZero() && stats.FinishedAt.IsZero() {
return c.JSON(http.StatusPreconditionFailed, map[string]string{
"message": "Migration already running",
"running_since": stats.StartedAt.String(),
})
@ -95,7 +95,7 @@ func (mw *MigrationWeb) Migrate(c echo.Context) error {
return handler.HandleHTTPError(err, c)
}
return c.JSON(http.StatusOK, models.Message{Message: "Everything was migrated successfully."})
return c.JSON(http.StatusOK, models.Message{Message: "Migration was started successfully."})
}
// Status returns whether or not a user has already done this migration