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) => {
|
ipcMain.on(Constants.IPC_Delete_File, (event, data) => {
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(data.FilePath)) {
|
if (fs.existsSync(data.FilePath)) {
|
||||||
|
|||||||
@@ -656,7 +656,7 @@ class App extends Component {
|
|||||||
dependencies={this.state.MissingDependencies}
|
dependencies={this.state.MissingDependencies}
|
||||||
onDownload={this.handleDependencyDownload}/>
|
onDownload={this.handleDependencyDownload}/>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let downloadDisplay = null;
|
let downloadDisplay = null;
|
||||||
@@ -665,7 +665,8 @@ class App extends Component {
|
|||||||
<Modal>
|
<Modal>
|
||||||
<DownloadProgress display={this.state.DownloadName}
|
<DownloadProgress display={this.state.DownloadName}
|
||||||
progress={this.state.DownloadProgress}/>
|
progress={this.state.DownloadProgress}/>
|
||||||
</Modal>);
|
</Modal>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let upgradeDisplay = null;
|
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 = 'check_installed';
|
||||||
exports.IPC_Check_Installed_Reply = 'check_installed_reply';
|
exports.IPC_Check_Installed_Reply = 'check_installed_reply';
|
||||||
|
|
||||||
|
exports.IPC_Check_Mount_Location = 'check_mount_location';
|
||||||
|
|
||||||
exports.IPC_Delete_File = 'delete_file';
|
exports.IPC_Delete_File = 'delete_file';
|
||||||
|
|
||||||
exports.IPC_Detect_Mounts = 'detect_mounts';
|
exports.IPC_Detect_Mounts = 'detect_mounts';
|
||||||
|
|||||||
@@ -58,34 +58,51 @@ class MountItems extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
handleMountUnMount = (storageType, mount, location) => {
|
handleMountUnMount = (storageType, mount, location) => {
|
||||||
if (ipcRenderer) {
|
if (!location || (location.trim().length === 0)) {
|
||||||
const state = {
|
this.props.errorHandler('Mount location is not set');
|
||||||
...this.state[storageType],
|
} else {
|
||||||
AllowMount: false,
|
if (ipcRenderer) {
|
||||||
};
|
let allowAction = true;
|
||||||
|
if (mount && (this.props.platform !== 'win32')) {
|
||||||
this.props.mountsBusy(true);
|
const result = ipcRenderer.sendSync(Constants.IPC_Check_Mount_Location, {
|
||||||
|
|
||||||
this.setState({
|
|
||||||
[storageType]: state,
|
|
||||||
}, ()=> {
|
|
||||||
if (mount) {
|
|
||||||
ipcRenderer.send(Constants.IPC_Mount_Drive, {
|
|
||||||
Directory: this.props.directory,
|
|
||||||
Location: location,
|
Location: location,
|
||||||
NoConsoleSupported: this.props.noConsoleSupported,
|
|
||||||
StorageType: storageType,
|
|
||||||
Version: this.props.version,
|
|
||||||
});
|
});
|
||||||
} else {
|
if (!result.Success) {
|
||||||
ipcRenderer.send(Constants.IPC_Unmount_Drive, {
|
allowAction = false;
|
||||||
Directory: this.props.directory,
|
this.props.errorHandler(result.Error.toString());
|
||||||
Location: location,
|
}
|
||||||
StorageType: storageType,
|
}
|
||||||
Version: this.props.version,
|
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user