feat: display warning for migration errors
This commit is contained in:
parent
d555f0fdf4
commit
4ed292f6c0
13 changed files with 126 additions and 49 deletions
|
@ -58,12 +58,17 @@ async function migrateFromTo(oldMigrationVersion, targetMigrationVersion) {
|
|||
{ permanent: true },
|
||||
);
|
||||
|
||||
/** @type {Result} */
|
||||
let result = "success";
|
||||
for (const [i, { migrate }] of migrationsToExecute.entries()) {
|
||||
const currentMigrationVersion = oldMigrationVersion + i + 1;
|
||||
logger.info("executing migration script", currentMigrationVersion);
|
||||
try {
|
||||
await migrate();
|
||||
const r = await migrate();
|
||||
getGame().settings.set("ds4", "systemMigrationVersion", currentMigrationVersion);
|
||||
if (r === "error") {
|
||||
result = "error";
|
||||
}
|
||||
} catch (err) {
|
||||
notifications.error(
|
||||
getGame().i18n.format("DS4.ErrorDuringMigration", {
|
||||
|
@ -78,13 +83,23 @@ async function migrateFromTo(oldMigrationVersion, targetMigrationVersion) {
|
|||
}
|
||||
}
|
||||
|
||||
notifications.info(
|
||||
getGame().i18n.format("DS4.InfoSystemUpdateCompleted", {
|
||||
currentVersion: oldMigrationVersion,
|
||||
targetVersion: targetMigrationVersion,
|
||||
}),
|
||||
{ permanent: true },
|
||||
);
|
||||
if (result === "success") {
|
||||
notifications.info(
|
||||
getGame().i18n.format("DS4.InfoSystemUpdateCompletedSuccessfully", {
|
||||
currentVersion: oldMigrationVersion,
|
||||
targetVersion: targetMigrationVersion,
|
||||
}),
|
||||
{ permanent: true },
|
||||
);
|
||||
} else {
|
||||
notifications.warn(
|
||||
getGame().i18n.format("DS4.WarningSystemUpdateCompletedWithErrors", {
|
||||
currentVersion: oldMigrationVersion,
|
||||
targetVersion: targetMigrationVersion,
|
||||
}),
|
||||
{ permanent: true },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,9 +174,11 @@ function getTargetMigrationVersion() {
|
|||
return migrations.length;
|
||||
}
|
||||
|
||||
/** @typedef {"success" | "error"} Result */
|
||||
|
||||
/**
|
||||
* @typedef {object} Migration
|
||||
* @property {() => Promise<void>} migrate
|
||||
* @property {() => Promise<Result>} migrate
|
||||
* @property {import("./migrationHelpers").CompendiumMigrator} migrateCompendium
|
||||
*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue