mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 00:29:59 +01:00
some tweaks mainly for electron support
This commit is contained in:
16
app.js
16
app.js
@@ -10,6 +10,7 @@ const os = require('os');
|
||||
const options = require('./services/options');
|
||||
const log = require('./services/log');
|
||||
const utils = require('./services/utils');
|
||||
const sql = require('./services/sql');
|
||||
|
||||
const dataDir = require('./services/data_dir');
|
||||
const sessionSecret = require('./services/session_secret');
|
||||
@@ -17,6 +18,15 @@ const sessionSecret = require('./services/session_secret');
|
||||
const db = require('sqlite');
|
||||
|
||||
db.open(dataDir.DOCUMENT_PATH, { Promise }).then(async () => {
|
||||
const tableResults = await sql.getResults("SELECT name FROM sqlite_master WHERE type='table' AND name='notes'");
|
||||
|
||||
console.log(tableResults);
|
||||
|
||||
if (tableResults.length !== 1) {
|
||||
console.log("No connection to initialized DB.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!await options.getOption('document_id')) {
|
||||
await options.setOption('document_id', utils.randomString(32));
|
||||
}
|
||||
@@ -24,7 +34,11 @@ db.open(dataDir.DOCUMENT_PATH, { Promise }).then(async () => {
|
||||
if (!await options.getOption('document_secret')) {
|
||||
await options.setOption('document_secret', utils.randomSecureToken(32));
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
console.log("Error connecting to DB.", e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
const app = express();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user