mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
beginning of #98, new multistep wizard, db creation after user enters username and password
This commit is contained in:
@@ -5,6 +5,7 @@ const sqlite = require('sqlite');
|
||||
const resourceDir = require('./resource_dir');
|
||||
const appInfo = require('./app_info');
|
||||
const sql = require('./sql');
|
||||
const options = require('./options');
|
||||
const cls = require('./cls');
|
||||
|
||||
async function createConnection() {
|
||||
@@ -30,7 +31,9 @@ const dbReady = new Promise((resolve, reject) => {
|
||||
|
||||
const tableResults = await sql.getRows("SELECT name FROM sqlite_master WHERE type='table' AND name='notes'");
|
||||
if (tableResults.length !== 1) {
|
||||
await createInitialDatabase();
|
||||
log.info("DB not found, please visit setup page to initialize Trilium.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
schemaReadyResolve();
|
||||
@@ -52,7 +55,7 @@ const dbReady = new Promise((resolve, reject) => {
|
||||
});
|
||||
});
|
||||
|
||||
async function createInitialDatabase() {
|
||||
async function createInitialDatabase(username, password) {
|
||||
log.info("Connected to db, but schema doesn't exist. Initializing schema ...");
|
||||
|
||||
const schema = fs.readFileSync(resourceDir.DB_INIT_DIR + '/schema.sql', 'UTF-8');
|
||||
@@ -70,14 +73,13 @@ async function createInitialDatabase() {
|
||||
|
||||
const startNoteId = await sql.getValue("SELECT noteId FROM branches WHERE parentNoteId = 'root' AND isDeleted = 0 ORDER BY notePosition");
|
||||
|
||||
await require('./options').initOptions(startNoteId);
|
||||
await require('./options_init').initOptions(startNoteId, username, password);
|
||||
await require('./sync_table').fillAllSyncRows();
|
||||
});
|
||||
|
||||
log.info("Schema and initial content generated. Waiting for user to enter username/password to finish setup.");
|
||||
|
||||
// we don't resolve dbReady promise because user needs to setup the username and password to initialize
|
||||
// the database
|
||||
setDbReadyAsResolved();
|
||||
}
|
||||
|
||||
function setDbReadyAsResolved() {
|
||||
@@ -113,5 +115,6 @@ module.exports = {
|
||||
schemaReady,
|
||||
isUserInitialized,
|
||||
setDbReadyAsResolved,
|
||||
isDbUpToDate
|
||||
isDbUpToDate,
|
||||
createInitialDatabase
|
||||
};
|
||||
Reference in New Issue
Block a user