Check mount location

This commit is contained in:
Scott E. Graves
2018-12-12 10:28:04 -06:00
parent eb5198d601
commit e223eac541
4 changed files with 69 additions and 26 deletions

View File

@@ -58,34 +58,51 @@ class MountItems extends Component {
};
handleMountUnMount = (storageType, mount, location) => {
if (ipcRenderer) {
const state = {
...this.state[storageType],
AllowMount: false,
};
this.props.mountsBusy(true);
this.setState({
[storageType]: state,
}, ()=> {
if (mount) {
ipcRenderer.send(Constants.IPC_Mount_Drive, {
Directory: this.props.directory,
if (!location || (location.trim().length === 0)) {
this.props.errorHandler('Mount location is not set');
} else {
if (ipcRenderer) {
let allowAction = true;
if (mount && (this.props.platform !== 'win32')) {
const result = ipcRenderer.sendSync(Constants.IPC_Check_Mount_Location, {
Location: location,
NoConsoleSupported: this.props.noConsoleSupported,
StorageType: storageType,
Version: this.props.version,
});
} else {
ipcRenderer.send(Constants.IPC_Unmount_Drive, {
Directory: this.props.directory,
Location: location,
StorageType: storageType,
Version: this.props.version,
if (!result.Success) {
allowAction = false;
this.props.errorHandler(result.Error.toString());
}
}
if (allowAction) {
const state = {
...this.state[storageType],
AllowMount: false,
};
this.props.mountsBusy(true);
this.setState({
[storageType]: state,
}, () => {
if (mount) {
ipcRenderer.send(Constants.IPC_Mount_Drive, {
Directory: this.props.directory,
Location: location,
NoConsoleSupported: this.props.noConsoleSupported,
StorageType: storageType,
Version: this.props.version,
});
} else {
ipcRenderer.send(Constants.IPC_Unmount_Drive, {
Directory: this.props.directory,
Location: location,
StorageType: storageType,
Version: this.props.version,
});
}
});
}
});
}
}
};