Version check/upgrade improvements

- Upgrading is now optional
  - Move version comparison logic into JS (Jack took it out of the daemon)
This commit is contained in:
Alex Liebowitz 2016-05-30 09:43:34 -04:00
parent 92105f1bf4
commit 5f5e3ae5c6
2 changed files with 32 additions and 23 deletions

View file

@ -17,26 +17,29 @@ var App = React.createClass({
},
componentWillMount: function() {
lbry.checkNewVersionAvailable(function(isAvailable) {
if (isAvailable) {
var message = "The version of LBRY you're using is not up to date.\n\n" +
"You'll now be taken to lbry.io, where you can download the latest version.";
lbry.getVersionInfo(function(versionInfo) {
var maj, min, patch;
[maj, min, patch] = versionInfo.lbrynet_version.split('.');
if (versionInfo.os_system == 'Darwin' && maj == 0 && min <= 2 && patch <= 2) {
// On OS X with version <= 0.2.2, we need to notify user to close manually close LBRY
message += "\n\nBefore installing the new version, make sure to exit LBRY, if you started the app " +
"click that LBRY icon in your status bar and choose \"Quit.\"";
} else {
lbry.stop();
}
alert(message);
window.location = "http://www.lbry.io/" + (versionInfo.os_system == 'Darwin' ? 'osx' : 'linux');
});
if (!isAvailable) {
return;
}
var message = 'The version of LBRY you\'re using is not up to date.\n\n' +
'Would you like to visit lbry.io now to get the latest version?';
lbry.getVersionInfo(function(versionInfo) {
var maj, min, patch;
[maj, min, patch] = versionInfo.lbrynet_version.split('.');
if (versionInfo.os_system == 'Darwin' && maj == 0 && min <= 2 && patch <= 2) {
// On OS X with version <= 0.2.2, we need to notify user to close manually close LBRY
message += '\n\nBefore installing the new version, make sure to exit LBRY, if you started the app ' +
'click that LBRY icon in your status bar and choose "Quit."';
} else {
lbry.stop();
}
if (window.confirm(message)) {
window.location = 'http://www.lbry.io/get';
};
});
});
},
render: function() {

View file

@ -135,12 +135,18 @@ lbry.getVersionInfo = function(callback) {
};
lbry.checkNewVersionAvailable = function(callback) {
lbry.call('version', {}, function() {
// If the "version" method is available, we have a daemon new enough to do version checking
lbry.call('check_for_new_version', {}, callback);
lbry.call('version', {}, function(versionInfo) {
var maj, min, patch;
[maj, min, patch] = versionInfo.lbrynet_version.split('.');
var remoteMaj, remoteMin, remotePatch;
[remoteMaj, remoteMin, remotePatch] = versionInfo.remote_lbrynet.split('.');
var newVersionAvailable = (maj < remoteMaj || min < remoteMin || patch < remotePatch);
callback(newVersionAvailable);
}, function(err) {
if (err.fault == 'NoSuchFunction') {
// If it's not available, we're definitely in an old version
// Really old daemon that can't report a version
callback(true);
}
});