From 01c7e58d4787d2aeea03302cbedc8ec21c68a156 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 30 Jul 2018 16:45:34 +0200 Subject: [PATCH] check if sync is configured every minute, not just at app startup, fixes #138 --- src/services/sync.js | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/services/sync.js b/src/services/sync.js index 51b42c98e..c161f5c9b 100644 --- a/src/services/sync.js +++ b/src/services/sync.js @@ -304,31 +304,20 @@ async function setLastSyncedPush(lastSyncedPush) { } async function updatePushStats() { - const lastSyncedPush = await optionService.getOption('lastSyncedPush'); + if (await syncOptions.isSyncSetup()) { + const lastSyncedPush = await optionService.getOption('lastSyncedPush'); - stats.outstandingPushes = await sql.getValue("SELECT COUNT(*) FROM sync WHERE id > ?", [lastSyncedPush]); + stats.outstandingPushes = await sql.getValue("SELECT COUNT(*) FROM sync WHERE id > ?", [lastSyncedPush]); + } } sqlInit.dbReady.then(async () => { - if (await syncOptions.isSyncSetup()) { - log.info("Setting up sync to " + await syncOptions.getSyncServerHost() + " with timeout " + await syncOptions.getSyncTimeout()); + setInterval(cls.wrap(sync), 60000); - const syncProxy = await syncOptions.getSyncProxy(); + // kickoff initial sync immediately + setTimeout(cls.wrap(sync), 1000); - if (syncProxy) { - log.info("Sync proxy: " + syncProxy); - } - - setInterval(cls.wrap(sync), 60000); - - // kickoff initial sync immediately - setTimeout(cls.wrap(sync), 1000); - - setInterval(cls.wrap(updatePushStats), 1000); - } - else { - log.info("Sync server not configured, sync timer not running.") - } + setInterval(cls.wrap(updatePushStats), 1000); }); module.exports = {