diff --git a/Gruntfile.js b/Gruntfile.js index 28c89ed7..328dd198 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,7 +17,7 @@ module.exports = function(grunt) { var pkg = require('./package.json'); var dt = new Date().toISOString().replace(/T.*/, ''); var electronVersion = '0.36.4'; - var appUpdateMinVersion = '0.5.0'; + var minElectronVersionForUpdate = '0.32.0'; function replaceFont(css) { css.walkAtRules('font-face', function (rule) { @@ -154,7 +154,7 @@ module.exports = function(grunt) { options: { replacements: [ { pattern: '# YYYY-MM-DD:v0.0.0', replacement: '# ' + dt + ':v' + pkg.version }, - { pattern: '# updmin:v0.0.0', replacement: '# updmin:v' + appUpdateMinVersion } + { pattern: '# updmin:v0.0.0', replacement: '# updmin:v' + minElectronVersionForUpdate } ] }, files: { 'dist/manifest.appcache': 'app/manifest.appcache' } diff --git a/app/scripts/comp/launcher.js b/app/scripts/comp/launcher.js index 3149ae58..7c4b685c 100644 --- a/app/scripts/comp/launcher.js +++ b/app/scripts/comp/launcher.js @@ -20,9 +20,6 @@ if (window.process && window.process.versions && window.process.versions.electro openDevTools: function() { this.req('remote').getCurrentWindow().openDevTools(); }, - getAppVersion: function() { - return this.remReq('app').getVersion(); - }, getSaveFileName: function(defaultPath, cb) { if (defaultPath) { var homePath = this.remReq('app').getPath('userDesktop'); diff --git a/app/scripts/comp/updater.js b/app/scripts/comp/updater.js index 7d6cf6cd..6e46e4a7 100644 --- a/app/scripts/comp/updater.js +++ b/app/scripts/comp/updater.js @@ -65,10 +65,10 @@ var Updater = { }, check: function(startedByUser) { - if (!Launcher || this.updateInProgress()) { + if (!startedByUser) { return; } - if (this.checkManualDownload()) { + if (!Launcher || this.updateInProgress()) { return; } UpdateModel.instance.set('status', 'checking'); @@ -111,6 +111,9 @@ var Updater = { }); UpdateModel.instance.save(); that.scheduleNextCheck(); + if (!that.canAutoUpdate()) { + return; + } if (prevLastVersion === UpdateModel.instance.get('lastVersion') && UpdateModel.instance.get('updateStatus') === 'ready') { logger.info('Waiting for the user to apply downloaded update'); @@ -135,11 +138,24 @@ var Updater = { }); }, - checkManualDownload: function() { - //if (+Launcher.getAppVersion().split('.')[1] <= 2) { - // UpdateModel.instance.set({ updateStatus: 'ready', updateManual: true }); - // return true; - //} + canAutoUpdate: function() { + var launcherVersion = Launcher.version.split('.'); + var minLauncherVersion = UpdateModel.instance.get('lastCheckUpdMin'); + if (minLauncherVersion) { + minLauncherVersion = minLauncherVersion.split('.'); + for (var num = 0; num < minLauncherVersion.length; num++) { + var min = minLauncherVersion[num] | 0, + actual = launcherVersion[num] | 0; + if (min < actual) { + return true; + } + if (min > actual) { + UpdateModel.instance.set({ updateStatus: 'ready', updateManual: true }); + return false; + } + } + } + return true; }, update: function(startedByUser, successCallback) {