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>
|
<h1>{{ $t('migrate.titleService', {name: migrator.name}) }}</h1>
|
||||||
<p>{{ $t('migrate.descriptionDo') }}</p>
|
<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="isMigrating === false">
|
||||||
<template v-if="migrator.isFileMigrator">
|
<template v-if="migrator.isFileMigrator">
|
||||||
<p>{{ $t('migrate.importUpload', {name: migrator.name}) }}</p>
|
<p>{{ $t('migrate.importUpload', {name: migrator.name}) }}</p>
|
||||||
@ -54,9 +54,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-else-if="lastMigrationStartedAt && lastMigrationFinishedAt === null">
|
<div v-else-if="lastMigrationStartedAt && lastMigrationFinishedAt === null">
|
||||||
<p>
|
<Message class="mb-4">
|
||||||
{{ $t('migrate.migrationInProgress') }}
|
{{ $t('migrate.migrationInProgress') }}
|
||||||
</p>
|
</Message>
|
||||||
<x-button :to="{name: 'home'}">
|
<x-button :to="{name: 'home'}">
|
||||||
{{ $t('home.goToOverview') }}
|
{{ $t('home.goToOverview') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
@ -170,19 +170,18 @@ async function initMigration() {
|
|||||||
if (!migratorAuthCode.value) {
|
if (!migratorAuthCode.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const {startedAt, finishedAt} = await migrationService.getStatus()
|
const {started_at, finished_at} = await migrationService.getStatus()
|
||||||
if (startedAt) {
|
if (started_at) {
|
||||||
lastMigrationStartedAt.value = parseDateOrNull(startedAt)
|
lastMigrationStartedAt.value = parseDateOrNull(started_at)
|
||||||
}
|
}
|
||||||
if (finishedAt) {
|
if (finished_at) {
|
||||||
lastMigrationFinishedAt.value = parseDateOrNull(finishedAt)
|
lastMigrationFinishedAt.value = parseDateOrNull(finished_at)
|
||||||
if (lastMigrationFinishedAt.value) {
|
if (lastMigrationFinishedAt.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMigrationStartedAt.value && lastMigrationFinishedAt.value === null) {
|
if (lastMigrationStartedAt.value && lastMigrationFinishedAt.value === null) {
|
||||||
// Migration already in progress
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,6 +213,8 @@ async function migrate() {
|
|||||||
message.value = result.message
|
message.value = result.message
|
||||||
const projectStore = useProjectStore()
|
const projectStore = useProjectStore()
|
||||||
return projectStore.loadProjects()
|
return projectStore.loadProjects()
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
} finally {
|
} finally {
|
||||||
isMigrating.value = false
|
isMigrating.value = false
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ func (mw *MigrationWeb) Migrate(c echo.Context) error {
|
|||||||
return handler.HandleHTTPError(err, c)
|
return handler.HandleHTTPError(err, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if stats.FinishedAt.IsZero() {
|
if !stats.StartedAt.IsZero() && stats.FinishedAt.IsZero() {
|
||||||
return c.JSON(http.StatusOK, map[string]string{
|
return c.JSON(http.StatusPreconditionFailed, map[string]string{
|
||||||
"message": "Migration already running",
|
"message": "Migration already running",
|
||||||
"running_since": stats.StartedAt.String(),
|
"running_since": stats.StartedAt.String(),
|
||||||
})
|
})
|
||||||
@ -95,7 +95,7 @@ func (mw *MigrationWeb) Migrate(c echo.Context) error {
|
|||||||
return handler.HandleHTTPError(err, c)
|
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
|
// Status returns whether or not a user has already done this migration
|
||||||
|
Loading…
x
Reference in New Issue
Block a user