Skip to content

Build your personal knowledge base with Trilium Notes

fixed app termination after unsuccessful migration for electron

azivner48684d050991
diff --git a/src/services/migration.js b/src/services/migration.js
index a863c457d2..7265010cec 100644
--- a/src/services/migration.js
+++ b/src/services/migration.js
@@ -4,6 +4,7 @@ const sqlInit = require('./sql_init');
const optionService = require('./options');
const fs = require('fs-extra');
const log = require('./log');
+const utils = require('./utils');
const resourceDir = require('./resource_dir');
async function migrate() {
@@ -72,7 +73,7 @@ async function migrate() {
log.error("error during migration to version " + mig.dbVersion + ": " + e.stack);
log.error("migration failed, crashing hard"); // this is not very user friendly :-/
- process.exit(1);
+ utils.crash();
}
finally {
// make sure foreign keys are enabled even if migration script disables them
diff --git a/src/services/utils.js b/src/services/utils.js
index e88f2cf60f..2f1884abeb 100644
--- a/src/services/utils.js
+++ b/src/services/utils.js
@@ -118,6 +118,15 @@ function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
+function crash() {
+ if (isElectron()) {
+ require('electron').app.exit(1);
+ }
+ else {
+ process.exit(1);
+ }
+}
+
module.exports = {
randomSecureToken,
randomString,
@@ -137,5 +146,6 @@ module.exports = {
stripTags,
intersection,
union,
- escapeRegExp
+ escapeRegExp,
+ crash
};
\ No newline at end of file