mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
make sure to wait for DB connection to be up before starting ...
This commit is contained in:
parent
9ca4a016eb
commit
2259e1d44d
@ -30,6 +30,8 @@ function onClosed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createMainWindow() {
|
async function createMainWindow() {
|
||||||
|
await sqlInit.dbConnection;
|
||||||
|
|
||||||
// if schema doesn't exist -> setup process
|
// if schema doesn't exist -> setup process
|
||||||
// if schema exists, then we need to wait until the migration process is finished
|
// if schema exists, then we need to wait until the migration process is finished
|
||||||
if (await sqlInit.schemaExists()) {
|
if (await sqlInit.schemaExists()) {
|
||||||
|
@ -14,13 +14,19 @@ async function createConnection() {
|
|||||||
return await sqlite.open(dataDir.DOCUMENT_PATH, {Promise});
|
return await sqlite.open(dataDir.DOCUMENT_PATH, {Promise});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dbConnection = new Promise(async (resolve, reject) => {
|
||||||
|
// no need to create new connection now since DB stays the same all the time
|
||||||
|
const db = await createConnection();
|
||||||
|
sql.setDbConnection(db);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
let dbReadyResolve = null;
|
let dbReadyResolve = null;
|
||||||
const dbReady = new Promise(async (resolve, reject) => {
|
const dbReady = new Promise(async (resolve, reject) => {
|
||||||
dbReadyResolve = resolve;
|
dbReadyResolve = resolve;
|
||||||
|
|
||||||
// no need to create new connection now since DB stays the same all the time
|
await dbConnection;
|
||||||
const db = await createConnection();
|
|
||||||
sql.setDbConnection(db);
|
|
||||||
|
|
||||||
initDbConnection();
|
initDbConnection();
|
||||||
});
|
});
|
||||||
@ -165,6 +171,7 @@ dbReady.then(async () => {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
dbReady,
|
dbReady,
|
||||||
|
dbConnection,
|
||||||
schemaExists,
|
schemaExists,
|
||||||
isDbInitialized,
|
isDbInitialized,
|
||||||
initDbConnection,
|
initDbConnection,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user