diff --git a/public/electron.js b/public/electron.js index 7f17196..358b646 100644 --- a/public/electron.js +++ b/public/electron.js @@ -584,6 +584,7 @@ ipcMain.on(Constants.IPC_Download_File, (event, data) => { ipcMain.on(Constants.IPC_Extract_Release, (event, data) => { const destination = path.join(helpers.getDataDirectory(), data.Version); + helpers.removeDirectoryRecursively(destination); helpers.mkDirByPathSync(destination); const stream = fs.createReadStream(data.Source); @@ -968,6 +969,17 @@ ipcMain.on(Constants.IPC_Show_Window + '_sync', event => { event.returnValue = true; }); +ipcMain.on(Constants.IPC_Test_Release, (event, data) => { + helpers + .testRepertoryBinary(data.Version) + .then(() => { + standardIPCReply(event, Constants.IPC_Test_Release_Reply, {}); + }) + .catch(error => { + standardIPCReply(event, Constants.IPC_Test_Release_Reply, {}, error); + }); +}); + ipcMain.on(Constants.IPC_Unmount_All_Drives, (event, data) => { unmountAllDrives(); standardIPCReply(event, Constants.IPC_Unmount_All_Drives_Reply); diff --git a/src/containers/SelectAppPlatform/SelectAppPlatform.js b/src/containers/SelectAppPlatform/SelectAppPlatform.js index 10f4f2e..c24e200 100644 --- a/src/containers/SelectAppPlatform/SelectAppPlatform.js +++ b/src/containers/SelectAppPlatform/SelectAppPlatform.js @@ -1,13 +1,16 @@ import React from 'react'; -import IPCContainer from '../IPCContainer/IPCContainer'; import './SelectAppPlatform.css'; -import * as Constants from '../../constants'; +import axios from 'axios'; import {connect} from 'react-redux'; +import * as Constants from '../../constants'; import Box from '../../components/UI/Box/Box'; import Button from '../../components/UI/Button/Button'; -import {downloadItem} from '../../redux/actions/download_actions'; +import { + downloadItem, + setAllowDownload +} from '../../redux/actions/download_actions'; import DropDown from '../../components/UI/DropDown/DropDown'; -import axios from 'axios'; +import IPCContainer from '../IPCContainer/IPCContainer'; import {notifyError} from '../../redux/actions/error_actions'; import {setInstallTestActive} from '../../redux/actions/install_actions'; @@ -20,6 +23,7 @@ class SelectAppPlatform extends IPCContainer { const errorHandler = error => { this.props.notifyError(error); this.props.setInstallTestActive(false); + this.props.setAllowDownload(false); }; axios .get(Constants.RELEASES_URL) @@ -40,6 +44,7 @@ class SelectAppPlatform extends IPCContainer { handleTestClicked = () => { this.props.setInstallTestActive(true); + this.props.setAllowDownload(true); this.grabLatestRelease(Constants.LINUX_SELECTABLE_PLATFORMS[this.state.Selected]) }; @@ -76,6 +81,7 @@ const mapDispatchToProps = dispatch => { return { downloadItem: (name, type, urls, isWinFSP, testVersion, appPlatform) => dispatch(downloadItem(name, type, urls, isWinFSP, testVersion, appPlatform)), notifyError: msg => dispatch(notifyError(msg)), + setAllowDownload: allow => dispatch(setAllowDownload(allow)), setInstallTestActive: active => dispatch(setInstallTestActive(active)), }; }; diff --git a/src/helpers.js b/src/helpers.js index dfb955a..c11e5c1 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -705,6 +705,23 @@ module.exports.stopMountProcessSync = (version, provider) => { process.unref(); }; +module.exports.testRepertoryBinary = version => { + return new Promise((resolve, reject) => { + const command = path.join(_getDataDirectory(), version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory'); + _executeProcess(command, ['-dc']) + .then(code => { + if (code === 0) { + resolve(); + } else { + reject(Error('Invalid exit code: ' + code)); + } + }) + .catch(error => { + reject(error); + }); + }); +}; + module.exports.verifyHash = (file, hash) => { return new Promise((resolve, reject) => { const platform = os.platform(); diff --git a/src/redux/actions/download_actions.js b/src/redux/actions/download_actions.js index 5002fbc..8d35fc8 100644 --- a/src/redux/actions/download_actions.js +++ b/src/redux/actions/download_actions.js @@ -55,6 +55,9 @@ export const downloadItem = (name, type, urls, isWinFSP, testVersion, appPlatfor break; } } else { + if (type === Constants.INSTALL_TYPES.TestRelease) { + this.props.setAllowDownload(false); + } dispatch(notifyError(result.Error)); } }; diff --git a/src/redux/actions/install_actions.js b/src/redux/actions/install_actions.js index 1550869..ae44dec 100644 --- a/src/redux/actions/install_actions.js +++ b/src/redux/actions/install_actions.js @@ -139,7 +139,7 @@ export const installDependency = (source, url, isWinFSP) => { export const installAndTestRelease = (source, version, appPlatform) => { return (dispatch, getState) => { - if (ipcRenderer && !getState().install.InstallTestActive) { + if (ipcRenderer && getState().install.InstallTestActive) { const extractReleaseComplete = (event, arg) => { ipcRenderer.send(Constants.IPC_Delete_File, { FilePath: source, @@ -153,6 +153,7 @@ export const installAndTestRelease = (source, version, appPlatform) => { dispatch(setLinuxAppPlatform(appPlatform)); dispatch(setInstallTestActive(false)); dispatch(displaySelectAppPlatform(false)); + dispatch(setAllowDownload(false)); dispatch(loadReleases()); } else { dispatch(notifyError(arg.data.Error));