server-esm: Make crash async

This commit is contained in:
Elian Doran 2024-07-18 23:26:21 +03:00
parent 8a30663d1e
commit 013f25a49b
No known key found for this signature in database
2 changed files with 6 additions and 7 deletions

View File

@ -20,7 +20,7 @@ async function migrate() {
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.");
utils.crash();
await utils.crash();
return;
}
@ -84,7 +84,7 @@ async function migrate() {
log.error("migration failed, crashing hard"); // this is not very user-friendly :-/
utils.crash();
break; // crash() above does not seem to work right away
break; // crash() is sometimes async
}
}
});
@ -135,7 +135,7 @@ async function migrateIfNecessary() {
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.`);
utils.crash();
await utils.crash();
}
if (!isDbUpToDate()) {

View File

@ -125,11 +125,10 @@ function escapeRegExp(str: string) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
function crash() {
async function crash() {
if (isElectron()) {
require('electron').app.exit(1);
}
else {
(await import("electron")).app.exit(1);
} else {
process.exit(1);
}
}