Check mount location
This commit is contained in:
23
electron.js
23
electron.js
@@ -261,6 +261,29 @@ ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on(Constants.IPC_Check_Mount_Location, (event, data) => {
|
||||
let response = {
|
||||
Success: true,
|
||||
Error: ''
|
||||
};
|
||||
|
||||
try {
|
||||
if (fs.existsSync(data.Location) && fs.statSync(data.Location).isDirectory()) {
|
||||
if (fs.readdirSync(data.Location).length !== 0) {
|
||||
response.Success = false;
|
||||
response.Error = 'Directory not empty: ' + data.Location;
|
||||
}
|
||||
} else {
|
||||
response.Success = false;
|
||||
response.Error = 'Directory not found: ' + data.Location;
|
||||
}
|
||||
} catch (e) {
|
||||
response.Success = false;
|
||||
response.Error = e.toString();
|
||||
}
|
||||
event.returnValue = response;
|
||||
});
|
||||
|
||||
ipcMain.on(Constants.IPC_Delete_File, (event, data) => {
|
||||
try {
|
||||
if (fs.existsSync(data.FilePath)) {
|
||||
|
||||
@@ -656,7 +656,7 @@ class App extends Component {
|
||||
dependencies={this.state.MissingDependencies}
|
||||
onDownload={this.handleDependencyDownload}/>
|
||||
</Modal>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
let downloadDisplay = null;
|
||||
@@ -665,7 +665,8 @@ class App extends Component {
|
||||
<Modal>
|
||||
<DownloadProgress display={this.state.DownloadName}
|
||||
progress={this.state.DownloadProgress}/>
|
||||
</Modal>);
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
let upgradeDisplay = null;
|
||||
|
||||
@@ -27,6 +27,8 @@ exports.IPC_Check_Dependency_Installed_Reply = 'check_dependency_installed';
|
||||
exports.IPC_Check_Installed = 'check_installed';
|
||||
exports.IPC_Check_Installed_Reply = 'check_installed_reply';
|
||||
|
||||
exports.IPC_Check_Mount_Location = 'check_mount_location';
|
||||
|
||||
exports.IPC_Delete_File = 'delete_file';
|
||||
|
||||
exports.IPC_Detect_Mounts = 'detect_mounts';
|
||||
|
||||
@@ -58,7 +58,22 @@ class MountItems extends Component {
|
||||
};
|
||||
|
||||
handleMountUnMount = (storageType, mount, location) => {
|
||||
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,
|
||||
});
|
||||
if (!result.Success) {
|
||||
allowAction = false;
|
||||
this.props.errorHandler(result.Error.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (allowAction) {
|
||||
const state = {
|
||||
...this.state[storageType],
|
||||
AllowMount: false,
|
||||
@@ -68,7 +83,7 @@ class MountItems extends Component {
|
||||
|
||||
this.setState({
|
||||
[storageType]: state,
|
||||
}, ()=> {
|
||||
}, () => {
|
||||
if (mount) {
|
||||
ipcRenderer.send(Constants.IPC_Mount_Drive, {
|
||||
Directory: this.props.directory,
|
||||
@@ -87,6 +102,8 @@ class MountItems extends Component {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onDetectMountsReply = (event, arg) => {
|
||||
|
||||
Reference in New Issue
Block a user