#98, new option "initialized" which indicates if setup has been finished

This commit is contained in:
azivner
2018-07-24 08:12:36 +02:00
parent 1fe7c62f5a
commit 013714cb5c
11 changed files with 130 additions and 57 deletions

View File

@@ -1,7 +1,25 @@
"use strict";
function setupPage(req, res) {
res.render('setup', {});
const sqlInit = require('../services/sql_init');
const setupService = require('../services/setup');
async function setupPage(req, res) {
if (await sqlInit.isDbInitialized()) {
res.redirect('/');
}
// we got here because DB is not completely initialized so if schema exists
// it means we're in sync in progress state.
const syncInProgress = await sqlInit.schemaExists();
if (syncInProgress) {
// trigger sync if it's not already running
setupService.triggerSync();
}
res.render('setup', {
syncInProgress: syncInProgress
});
}
module.exports = {