From de4ace5ada29b17befca59eff82b2d999cdf50b8 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 28 Aug 2018 21:13:40 +0200 Subject: [PATCH] overriding sync settings from config file, fixes #160 --- src/services/sync_options.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/services/sync_options.js b/src/services/sync_options.js index 79c2f4050..dc6f4c4bc 100644 --- a/src/services/sync_options.js +++ b/src/services/sync_options.js @@ -1,10 +1,22 @@ "use strict"; const optionService = require('./options'); +const config = require('./config'); + +/* + * Primary configuration for sync is in the options (document), but we allow to override + * these settings in config file. The reason for that is to avoid a mistake of loading a live/production + * document with live sync settings in a dev/debug environment. Changes would then successfully propagate + * to live sync server. + */ + +async function get(name) { + return config['Sync'][name] || await optionService.getOption(name); +} module.exports = { - getSyncServerHost: async () => await optionService.getOption('syncServerHost'), - isSyncSetup: async () => !!await optionService.getOption('syncServerHost'), - getSyncTimeout: async () => await optionService.getOption('syncServerTimeout'), - getSyncProxy: async () => await optionService.getOption('syncProxy') + getSyncServerHost: async () => await get('syncServerHost'), + isSyncSetup: async () => !!await get('syncServerHost'), + getSyncTimeout: async () => await get('syncServerTimeout'), + getSyncProxy: async () => await get('syncProxy') }; \ No newline at end of file