Light refactoring of upgrade process

- Use Node instead of lbrynet to get platform info
 - Factor out code that picks the download URI into its own function
 - Remove out-of-date code for checking old versions of MacOS
This commit is contained in:
Alex Liebowitz 2017-03-22 06:55:16 -04:00 committed by Alex Grintsvayg
parent f51b720e05
commit 052eef5f81

View file

@ -43,6 +43,17 @@ var App = React.createClass({
_upgradeDownloadItem: null,
_version: null,
getUpdateUrl: function() {
console.log('os.platform is', os.platform());
switch (os.platform()) {
case 'darwin':
return 'https://lbry.io/get/lbry.dmg';
case 'linux':
return 'https://lbry.io/get/lbry.deb';
case 'win32':
return 'https://lbry.io/get/lbry.exe'; // should now be msi
}
},
// Temporary workaround since electron-dl throws errors when you try to get the filename
getUpgradeFilename: function() {
if (os.platform() == 'darwin') {
@ -67,8 +78,6 @@ var App = React.createClass({
pageArgs: typeof val !== 'undefined' ? val : null,
errorInfo: null,
modal: null,
updateUrl: null,
isOldOSX: null,
downloadProgress: null,
downloadComplete: false,
};
@ -91,38 +100,20 @@ var App = React.createClass({
}
});
lbry.checkNewVersionAvailable((isAvailable) => {
if (!isAvailable || sessionStorage.getItem('upgradeSkipped')) {
if (!sessionStorage.getItem('upgradeSkipped')) {
lbry.checkNewVersionAvailable(({isAvailable}) => {
if (!isAvailable) {
return;
}
lbry.getVersionInfo((versionInfo) => {
this._version = versionInfo.lbrynet_version; // temp for building upgrade filename
var isOldOSX = false;
if (versionInfo.os_system == 'Darwin') {
var updateUrl = 'https://lbry.io/get/lbry.dmg';
var maj, min, patch;
[maj, min, patch] = versionInfo.lbrynet_version.split('.');
if (maj == 0 && min <= 2 && patch <= 2) {
isOldOSX = true;
}
} else if (versionInfo.os_system == 'Linux') {
var updateUrl = 'https://lbry.io/get/lbry.deb';
} else if (versionInfo.os_system == 'Windows') {
var updateUrl = 'https://lbry.io/get/lbry.exe';
} else {
var updateUrl = 'https://lbry.io/get';
}
this._version = versionInfo.lbrynet_version;
this.setState({
modal: 'upgrade',
isOldOSX: isOldOSX,
updateUrl: updateUrl,
})
});
});
});
}
},
openDrawer: function() {
sessionStorage.setItem('drawerOpen', true);
@ -288,11 +279,7 @@ var App = React.createClass({
<Modal isOpen={this.state.modal == 'upgrade'} contentLabel="Update available"
type="confirm" confirmButtonLabel="Upgrade" abortButtonLabel="Skip"
onConfirmed={this.handleUpgradeClicked} onAborted={this.handleSkipClicked}>
<p>Your version of LBRY is out of date and may be unreliable or insecure.</p>
{this.state.isOldOSX
? <p>Before installing the new version, make sure to exit LBRY. If you started the app, click the LBRY icon in your status bar and choose "Quit."</p>
: null}
Your version of LBRY is out of date and may be unreliable or insecure.
</Modal>
<Modal isOpen={this.state.modal == 'downloading'} contentLabel="Downloading Update" type="custom">
Downloading Update{this.state.downloadProgress ? `: ${this.state.downloadProgress}%` : null}