separated DB initialization methods into sql_init

This commit is contained in:
azivner
2018-04-02 21:25:20 -04:00
parent 6ab0cea4e3
commit 26e4ad9bf9
11 changed files with 133 additions and 116 deletions

View File

@@ -3,6 +3,7 @@
const log = require('./log');
const rp = require('request-promise');
const sql = require('./sql');
const sqlInit = require('./sql_init');
const optionService = require('./options');
const utils = require('./utils');
const sourceIdService = require('./source_id');
@@ -23,7 +24,7 @@ let syncServerCertificate = null;
async function sync() {
try {
await syncMutexService.doExclusively(async () => {
if (!await sql.isDbUpToDate()) {
if (!await sqlInit.isDbUpToDate()) {
return {
success: false,
message: "DB not up to date"
@@ -330,7 +331,7 @@ async function syncRequest(syncContext, method, uri, body) {
}
}
sql.dbReady.then(() => {
sqlInit.dbReady.then(() => {
if (syncSetup.isSyncSetup) {
log.info("Setting up sync to " + syncSetup.SYNC_SERVER + " with timeout " + syncSetup.SYNC_TIMEOUT);