fixed app termination after unsuccessful migration for electron

This commit is contained in:
azivner 2018-11-18 09:05:50 +01:00
parent 1ee8d9fd93
commit 48684d0509
2 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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
};