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:
parent
a12c169ce8
commit
205f330f8a
@ -3,7 +3,7 @@
|
||||
<h1>{{ $t('migrate.titleService', {name: migrator.name}) }}</h1>
|
||||
<p>{{ $t('migrate.descriptionDo') }}</p>
|
||||
|
||||
<template v-if="message === '' && lastMigrationFinishedAt === null">
|
||||
<template v-if="message === '' && lastMigrationStartedAt === null">
|
||||
<template v-if="isMigrating === false">
|
||||
<template v-if="migrator.isFileMigrator">
|
||||
<p>{{ $t('migrate.importUpload', {name: migrator.name}) }}</p>
|
||||
@ -54,9 +54,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<div v-else-if="lastMigrationStartedAt && lastMigrationFinishedAt === null">
|
||||
<p>
|
||||
<Message class="mb-4">
|
||||
{{ $t('migrate.migrationInProgress') }}
|
||||
</p>
|
||||
</Message>
|
||||
<x-button :to="{name: 'home'}">
|
||||
{{ $t('home.goToOverview') }}
|
||||
</x-button>
|
||||
@ -170,19 +170,18 @@ async function initMigration() {
|
||||
if (!migratorAuthCode.value) {
|
||||
return
|
||||
}
|
||||
const {startedAt, finishedAt} = await migrationService.getStatus()
|
||||
if (startedAt) {
|
||||
lastMigrationStartedAt.value = parseDateOrNull(startedAt)
|
||||
const {started_at, finished_at} = await migrationService.getStatus()
|
||||
if (started_at) {
|
||||
lastMigrationStartedAt.value = parseDateOrNull(started_at)
|
||||
}
|
||||
if (finishedAt) {
|
||||
lastMigrationFinishedAt.value = parseDateOrNull(finishedAt)
|
||||
if (finished_at) {
|
||||
lastMigrationFinishedAt.value = parseDateOrNull(finished_at)
|
||||
if (lastMigrationFinishedAt.value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (lastMigrationStartedAt.value && lastMigrationFinishedAt.value === null) {
|
||||
// Migration already in progress
|
||||
return
|
||||
}
|
||||
|
||||
@ -214,6 +213,8 @@ async function migrate() {
|
||||
message.value = result.message
|
||||
const projectStore = useProjectStore()
|
||||
return projectStore.loadProjects()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
isMigrating.value = false
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user