#36: Add ability to select Linux distribution type if OS is unsupported

This commit is contained in:
2019-08-28 21:20:30 -05:00
parent 0105602a44
commit 083b2192d7
5 changed files with 44 additions and 5 deletions

View File

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

View File

@@ -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)),
};
};

View File

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

View File

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

View File

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