[#27: Implement Bitbucket backup download location] [Prefer 'ipcRenderer.once()']
This commit is contained in:
@@ -109,7 +109,7 @@ class App extends IPCContainer {
|
|||||||
handleDownloadRelease = () => {
|
handleDownloadRelease = () => {
|
||||||
const selectedVersion = this.getSelectedVersion();
|
const selectedVersion = this.getSelectedVersion();
|
||||||
const fileName = selectedVersion + '.zip';
|
const fileName = selectedVersion + '.zip';
|
||||||
this.props.downloadItem(fileName, Constants.INSTALL_TYPES.Release, this.props.LocationsLookup[selectedVersion].urls[0], this.onDownloadFileComplete);
|
this.props.downloadItem(fileName, Constants.INSTALL_TYPES.Release, this.props.LocationsLookup[selectedVersion].urls, this.onDownloadFileComplete);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleDownloadUpgrade = () => {
|
handleDownloadUpgrade = () => {
|
||||||
@@ -118,7 +118,7 @@ class App extends IPCContainer {
|
|||||||
(this.props.Platform === 'darwin') ?
|
(this.props.Platform === 'darwin') ?
|
||||||
'upgrade.dmg' :
|
'upgrade.dmg' :
|
||||||
'repertory-ui_' + this.props.UpgradeVersion + '_linux_x86_64.AppImage';
|
'repertory-ui_' + this.props.UpgradeVersion + '_linux_x86_64.AppImage';
|
||||||
this.props.downloadItem(name, Constants.INSTALL_TYPES.Upgrade, this.props.UpgradeData.urls[0], this.onDownloadFileComplete);
|
this.props.downloadItem(name, Constants.INSTALL_TYPES.Upgrade, this.props.UpgradeData.urls, this.onDownloadFileComplete);
|
||||||
};
|
};
|
||||||
|
|
||||||
installDependency = result => {
|
installDependency = result => {
|
||||||
|
|||||||
@@ -19,33 +19,44 @@ export const setDownloadBegin = (name, type, url) => {
|
|||||||
export const setDownloadEnd = createAction('download/setDownloadEnd');
|
export const setDownloadEnd = createAction('download/setDownloadEnd');
|
||||||
export const setDownloadProgress = createAction('download/setDownloadProgress');
|
export const setDownloadProgress = createAction('download/setDownloadProgress');
|
||||||
|
|
||||||
export const downloadItem = (name, type, url, completedCallback) => {
|
export const downloadItem = (name, type, urls, completedCallback) => {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
if (!Array.isArray(urls)) {
|
||||||
if (!state.download.DownloadActive && state.download.AllowDownload) {
|
urls = [urls];
|
||||||
const ipcRenderer = getIPCRenderer();
|
|
||||||
if (ipcRenderer) {
|
|
||||||
dispatch(setDownloadBegin(name, type, url));
|
|
||||||
|
|
||||||
const downloadFileProgress = (_, arg) => {
|
|
||||||
dispatch(setDownloadProgress(arg.data.Progress));
|
|
||||||
};
|
|
||||||
|
|
||||||
const downloadFileComplete = (_, arg) => {
|
|
||||||
ipcRenderer.removeListener(Constants.IPC_Download_File_Progress, downloadFileProgress);
|
|
||||||
ipcRenderer.removeListener(Constants.IPC_Download_File_Complete, downloadFileComplete);
|
|
||||||
completedCallback(name, type, url, arg.data);
|
|
||||||
dispatch(setDownloadEnd(arg.data));
|
|
||||||
};
|
|
||||||
|
|
||||||
ipcRenderer.on(Constants.IPC_Download_File_Progress, downloadFileProgress);
|
|
||||||
ipcRenderer.on(Constants.IPC_Download_File_Complete, downloadFileComplete);
|
|
||||||
|
|
||||||
ipcRenderer.send(Constants.IPC_Download_File, {
|
|
||||||
Filename: name,
|
|
||||||
URL: url,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const downloadAtIndex = index => {
|
||||||
|
const url = urls[index];
|
||||||
|
const state = getState();
|
||||||
|
if ((index > 0) || (!state.download.DownloadActive && state.download.AllowDownload)) {
|
||||||
|
const ipcRenderer = getIPCRenderer();
|
||||||
|
if (ipcRenderer) {
|
||||||
|
dispatch(setDownloadBegin(name, type, url));
|
||||||
|
|
||||||
|
const downloadFileProgress = (_, arg) => {
|
||||||
|
dispatch(setDownloadProgress(arg.data.Progress));
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadFileComplete = (_, arg) => {
|
||||||
|
ipcRenderer.removeListener(Constants.IPC_Download_File_Progress, downloadFileProgress);
|
||||||
|
if (!arg.data.Success && (++index < urls.length)) {
|
||||||
|
downloadAtIndex(index);
|
||||||
|
} else {
|
||||||
|
completedCallback(name, type, url, arg.data);
|
||||||
|
dispatch(setDownloadEnd(arg.data));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ipcRenderer.on(Constants.IPC_Download_File_Progress, downloadFileProgress);
|
||||||
|
ipcRenderer.once(Constants.IPC_Download_File_Complete, downloadFileComplete);
|
||||||
|
|
||||||
|
ipcRenderer.send(Constants.IPC_Download_File, {
|
||||||
|
Filename: name,
|
||||||
|
URL: url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
downloadAtIndex(0);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -18,7 +18,6 @@ const ipcRenderer = getIPCRenderer();
|
|||||||
export const checkInstalled = (dependencies, version) => {
|
export const checkInstalled = (dependencies, version) => {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const checkInstalledComplete = (event, arg) => {
|
const checkInstalledComplete = (event, arg) => {
|
||||||
ipcRenderer.removeListener(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
|
|
||||||
const result = arg.data;
|
const result = arg.data;
|
||||||
const updateState = () => {
|
const updateState = () => {
|
||||||
const installedVersion = result.Success && result.Exists ? result.Version : 'none';
|
const installedVersion = result.Success && result.Exists ? result.Version : 'none';
|
||||||
@@ -48,7 +47,7 @@ export const checkInstalled = (dependencies, version) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.on(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
|
ipcRenderer.once(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
|
||||||
ipcRenderer.send(Constants.IPC_Check_Installed, {
|
ipcRenderer.send(Constants.IPC_Check_Installed, {
|
||||||
Dependencies: dependencies,
|
Dependencies: dependencies,
|
||||||
Version: version,
|
Version: version,
|
||||||
@@ -62,8 +61,6 @@ export const installDependency = (source, url, completedCallback) => {
|
|||||||
dispatch(setInstallActive(Constants.INSTALL_TYPES.Dependency));
|
dispatch(setInstallActive(Constants.INSTALL_TYPES.Dependency));
|
||||||
|
|
||||||
const installDependencyComplete = (event, arg) => {
|
const installDependencyComplete = (event, arg) => {
|
||||||
ipcRenderer.removeListener(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
|
|
||||||
|
|
||||||
const result = arg.data;
|
const result = arg.data;
|
||||||
const handleCompleted = ()=> {
|
const handleCompleted = ()=> {
|
||||||
ipcRenderer.send(Constants.IPC_Delete_File, {
|
ipcRenderer.send(Constants.IPC_Delete_File, {
|
||||||
@@ -94,7 +91,7 @@ export const installDependency = (source, url, completedCallback) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.on(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
|
ipcRenderer.once(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
|
||||||
ipcRenderer.send(Constants.IPC_Install_Dependency, {
|
ipcRenderer.send(Constants.IPC_Install_Dependency, {
|
||||||
Source: source,
|
Source: source,
|
||||||
URL: url,
|
URL: url,
|
||||||
@@ -109,7 +106,6 @@ export const installRelease = (source, version, completedCallback) => {
|
|||||||
dispatch(setInstallActive(Constants.INSTALL_TYPES.Release));
|
dispatch(setInstallActive(Constants.INSTALL_TYPES.Release));
|
||||||
|
|
||||||
const extractReleaseComplete = (event, arg) => {
|
const extractReleaseComplete = (event, arg) => {
|
||||||
ipcRenderer.removeListener(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
|
|
||||||
ipcRenderer.send(Constants.IPC_Delete_File, {
|
ipcRenderer.send(Constants.IPC_Delete_File, {
|
||||||
FilePath: source,
|
FilePath: source,
|
||||||
});
|
});
|
||||||
@@ -118,7 +114,7 @@ export const installRelease = (source, version, completedCallback) => {
|
|||||||
completedCallback(source, version, arg.data);
|
completedCallback(source, version, arg.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.on(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
|
ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
|
||||||
ipcRenderer.send(Constants.IPC_Extract_Release, {
|
ipcRenderer.send(Constants.IPC_Extract_Release, {
|
||||||
Source: source,
|
Source: source,
|
||||||
Version: version,
|
Version: version,
|
||||||
@@ -134,7 +130,6 @@ export const installUpgrade = (source, sha256, signature, skipVerification, comp
|
|||||||
dispatch(setApplicationReady(false));
|
dispatch(setApplicationReady(false));
|
||||||
|
|
||||||
const installUpgradeComplete = (event, arg) => {
|
const installUpgradeComplete = (event, arg) => {
|
||||||
ipcRenderer.removeListener(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
|
|
||||||
if (arg.data.Success) {
|
if (arg.data.Success) {
|
||||||
dispatch(shutdownApplication());
|
dispatch(shutdownApplication());
|
||||||
} else {
|
} else {
|
||||||
@@ -144,7 +139,7 @@ export const installUpgrade = (source, sha256, signature, skipVerification, comp
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.on(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
|
ipcRenderer.once(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
|
||||||
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
|
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
|
||||||
Sha256: sha256,
|
Sha256: sha256,
|
||||||
Signature: signature,
|
Signature: signature,
|
||||||
|
|||||||
Reference in New Issue
Block a user