diff --git a/ElectronClient/app/app.js b/ElectronClient/app/app.js index df60c0aea..a4d3c8d47 100644 --- a/ElectronClient/app/app.js +++ b/ElectronClient/app/app.js @@ -297,9 +297,13 @@ class Application extends BaseApplication { id: Setting.value('activeFolderId'), }); - setTimeout(() => { - bridge().checkForUpdatesAndNotify(reg.logger()); - }, 5000); + const runAutoUpdateCheck = function() { + bridge().checkForUpdatesAndNotify(Setting.value('profileDir') + '/log-autoupdater.txt'); + } + + setTimeout(() => { runAutoUpdateCheck() }, 5000); + // For those who leave the app always open + setInterval(() => { runAutoUpdateCheck() }, 2 * 60 * 60 * 1000); } } diff --git a/ElectronClient/app/bridge.js b/ElectronClient/app/bridge.js index 035f96182..fe6672ca2 100644 --- a/ElectronClient/app/bridge.js +++ b/ElectronClient/app/bridge.js @@ -1,4 +1,5 @@ const { _ } = require('lib/locale.js'); +const { Logger } = require('lib/logger.js'); class Bridge { @@ -66,11 +67,17 @@ class Bridge { return require('electron').shell.openItem(fullPath) } - checkForUpdatesAndNotify(logger) { - const autoUpdater = require("electron-updater").autoUpdater; - logger.info('Doing autoupdate checkForUpdatesAndNotify...'); - autoUpdater.logger = logger; - return autoUpdater.checkForUpdatesAndNotify(); + checkForUpdatesAndNotify(logFilePath) { + if (!this.autoUpdater_) { + const logger = new Logger(); + logger.addTarget('file', { path: logFilePath }); + logger.setLevel(Logger.LEVEL_DEBUG); + logger.info('checkForUpdatesAndNotify: Intializing...'); + this.autoUpdater_ = require("electron-updater").autoUpdater; + this.autoUpdater_.logger = logger; + } + + return this.autoUpdater_.checkForUpdatesAndNotify(); } } diff --git a/ElectronClient/app/main.js b/ElectronClient/app/main.js index de0cb9be3..08e2140c3 100644 --- a/ElectronClient/app/main.js +++ b/ElectronClient/app/main.js @@ -6,6 +6,8 @@ require('app-module-path').addPath(__dirname); const electronApp = require('electron').app; const { ElectronAppWrapper } = require('./ElectronAppWrapper'); const { initBridge } = require('./bridge'); +const { Logger } = require('lib/logger.js'); +const { FsDriverNode } = require('lib/fs-driver-node.js'); process.on('unhandledRejection', (reason, p) => { console.error('Unhandled promise rejection', p, 'reason:', reason); @@ -22,6 +24,8 @@ function envFromArgs(args) { return 'prod'; } +Logger.fsDriver_ = new FsDriverNode(); + const env = envFromArgs(process.argv); const wrapper = new ElectronAppWrapper(electronApp, env);