mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(startup): display migration errors using system modal
This commit is contained in:
parent
ca1d5207d8
commit
1c118f2aa9
@ -6,6 +6,7 @@ import { crash } from "./utils.js";
|
||||
import resourceDir from "./resource_dir.js";
|
||||
import appInfo from "./app_info.js";
|
||||
import cls from "./cls.js";
|
||||
import { t } from "i18next";
|
||||
|
||||
interface MigrationInfo {
|
||||
dbVersion: number;
|
||||
@ -18,9 +19,7 @@ async function migrate() {
|
||||
const currentDbVersion = getDbVersion();
|
||||
|
||||
if (currentDbVersion < 214) {
|
||||
log.error("Direct migration from your current version is not supported. Please upgrade to the latest v0.60.4 first and only then to this version.");
|
||||
|
||||
await crash();
|
||||
await crash(t("migration.old_version"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,10 +82,7 @@ async function migrate() {
|
||||
|
||||
log.info(`Migration to version ${mig.dbVersion} has been successful.`);
|
||||
} catch (e: any) {
|
||||
log.error(`error during migration to version ${mig.dbVersion}: ${e.stack}`);
|
||||
log.error("migration failed, crashing hard"); // this is not very user-friendly :-/
|
||||
|
||||
crash();
|
||||
crash(t("migration.error_message", { version: mig.dbVersion, stack: e.stack }));
|
||||
break; // crash() is sometimes async
|
||||
}
|
||||
}
|
||||
@ -136,11 +132,7 @@ async function migrateIfNecessary() {
|
||||
const currentDbVersion = getDbVersion();
|
||||
|
||||
if (currentDbVersion > appInfo.dbVersion && process.env.TRILIUM_IGNORE_DB_VERSION !== "true") {
|
||||
log.error(
|
||||
`Current DB version ${currentDbVersion} is newer than the current DB version ${appInfo.dbVersion}, which means that it was created by a newer and incompatible version of Trilium. Upgrade to the latest version of Trilium to resolve this issue.`
|
||||
);
|
||||
|
||||
await crash();
|
||||
await crash(t("migration.wrong_db_version", { version: currentDbVersion, targetVersion: appInfo.dbVersion }));
|
||||
}
|
||||
|
||||
if (!isDbUpToDate()) {
|
||||
|
@ -10,6 +10,8 @@ import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname, join } from "path";
|
||||
import type NoteMeta from "./meta/note_meta.js";
|
||||
import log from "./log.js";
|
||||
import { t } from "i18next";
|
||||
|
||||
const randtoken = generator({ source: "crypto" });
|
||||
|
||||
@ -105,10 +107,13 @@ export function escapeRegExp(str: string) {
|
||||
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
||||
}
|
||||
|
||||
export async function crash() {
|
||||
export async function crash(message: string) {
|
||||
if (isElectron) {
|
||||
(await import("electron")).app.exit(1);
|
||||
const electron = await import("electron");
|
||||
electron.dialog.showErrorBox(t("modals.error_title"), message);
|
||||
electron.app.exit(1);
|
||||
} else {
|
||||
log.error(message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -272,5 +272,13 @@
|
||||
"today": "Open today's journal note",
|
||||
"new-note": "New note",
|
||||
"show-windows": "Show windows"
|
||||
},
|
||||
"migration": {
|
||||
"old_version": "Direct migration from your current version is not supported. Please upgrade to the latest v0.60.4 first and only then to this version.",
|
||||
"error_message": "Error during migration to version {{version}}: {{stack}}",
|
||||
"wrong_db_version": "Current DB version {{version}} is newer than the current DB version {{targetVersion}}, which means that it was created by a newer and incompatible version of Trilium. Upgrade to the latest version of Trilium to resolve this issue."
|
||||
},
|
||||
"modals": {
|
||||
"error_title": "Error"
|
||||
}
|
||||
}
|
||||
|
@ -272,5 +272,13 @@
|
||||
"today": "Mergi la notița de astăzi",
|
||||
"tooltip": "TriliumNext Notes",
|
||||
"show-windows": "Afișează ferestrele"
|
||||
},
|
||||
"migration": {
|
||||
"error_message": "Eroare la migrarea către versiunea {{version}}: {{stack}}",
|
||||
"old_version": "Nu se poate migra la ultima versiune direct de la versiunea dvs. Actualizați mai întâi la versiunea v0.60.4 și ulterior la această versiune.",
|
||||
"wrong_db_version": "Versiunea actuală a bazei de date ({{version}}) este mai nouă decât versiunea de bază de date suportată de aplicație ({{targetVersion}}), ceea ce înseamnă că a fost creată de către o versiune mai nouă de Trilium. Actualizați aplicația la ultima versiune pentru a putea continua."
|
||||
},
|
||||
"modals": {
|
||||
"error_title": "Eroare"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user