mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 01:18:44 +02:00
fix migration in electron build
This commit is contained in:
parent
d467fbdff3
commit
bbd1774815
@ -31,7 +31,7 @@ function pad(data) {
|
||||
|
||||
function encrypt(key, iv, plainText) {
|
||||
if (!key) {
|
||||
throwError("No data key!");
|
||||
throw new Error("No data key!");
|
||||
}
|
||||
|
||||
const plainTextBuffer = Buffer.from(plainText);
|
||||
|
@ -5,7 +5,16 @@ const fs = require('fs-extra');
|
||||
const log = require('./log');
|
||||
const app_info = require('./app_info');
|
||||
|
||||
const MIGRATIONS_DIR = "migrations";
|
||||
let MIGRATIONS_DIR = "migrations";
|
||||
|
||||
if (!fs.existsSync(MIGRATIONS_DIR) && isElectron()) {
|
||||
MIGRATIONS_DIR = "resources/app/migrations";
|
||||
}
|
||||
|
||||
if (!fs.existsSync(MIGRATIONS_DIR)) {
|
||||
log.error("Could not find migration directory: " + MIGRATIONS_DIR);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
async function migrate() {
|
||||
const migrations = [];
|
||||
@ -58,7 +67,7 @@ async function migrate() {
|
||||
await migrationModule(db);
|
||||
}
|
||||
else {
|
||||
throwError("Unknown migration type " + mig.type);
|
||||
throw new Error("Unknown migration type " + mig.type);
|
||||
}
|
||||
|
||||
await options.setOption("db_version", mig.dbVersion);
|
||||
|
@ -28,7 +28,7 @@ async function createNewNote(parentNoteId, note) {
|
||||
await sync_table.addNoteReorderingSync(parentNoteId);
|
||||
}
|
||||
else {
|
||||
throwError('Unknown target: ' + note.target);
|
||||
throw new Error('Unknown target: ' + note.target);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ async function getOption(optName) {
|
||||
const row = await sql.getSingleResultOrNull("SELECT opt_value FROM options WHERE opt_name = ?", [optName]);
|
||||
|
||||
if (!row) {
|
||||
throwError("Option " + optName + " doesn't exist");
|
||||
throw new Error("Option " + optName + " doesn't exist");
|
||||
}
|
||||
|
||||
return row['opt_value'];
|
||||
|
@ -9,7 +9,7 @@ module.exports = function(req) {
|
||||
|
||||
function getDataKey() {
|
||||
if (!isProtectedSessionAvailable()) {
|
||||
throwError("Protected session is not available");
|
||||
throw new Error("Protected session is not available");
|
||||
}
|
||||
|
||||
return protected_session.getDataKey(req);
|
||||
|
@ -157,7 +157,7 @@ async function pullSync(syncContext) {
|
||||
await syncUpdate.updateRecentNotes(resp, syncContext.sourceId);
|
||||
}
|
||||
else {
|
||||
throwError("Unrecognized entity type " + sync.entity_name);
|
||||
throw new Error("Unrecognized entity type " + sync.entity_name);
|
||||
}
|
||||
|
||||
await setLastSyncedPull(sync.id);
|
||||
@ -228,7 +228,7 @@ async function readAndPushEntity(sync, syncContext) {
|
||||
entity = await sql.getSingleResult('SELECT * FROM recent_notes WHERE note_tree_id = ?', [sync.entity_id]);
|
||||
}
|
||||
else {
|
||||
throwError("Unrecognized entity type " + sync.entity_name);
|
||||
throw new Error("Unrecognized entity type " + sync.entity_name);
|
||||
}
|
||||
|
||||
if (!entity) {
|
||||
@ -302,7 +302,7 @@ async function syncRequest(syncContext, method, uri, body) {
|
||||
return await rp(options);
|
||||
}
|
||||
catch (e) {
|
||||
throwError("Request to " + method + " " + fullUri + " failed, inner exception: " + e.stack);
|
||||
throw new Error("Request to " + method + " " + fullUri + " failed, inner exception: " + e.stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user