check electron version in updater

This commit is contained in:
Antelle 2016-02-03 23:44:18 +03:00
parent 2fd6e11b46
commit f0d4125c97
3 changed files with 25 additions and 12 deletions

View File

@ -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' }

View File

@ -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');

View File

@ -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) {