Retry mount fixes
This commit is contained in:
@@ -6,7 +6,6 @@ import CSSModules from 'react-css-modules';
|
|||||||
import styles from './MountItems.css';
|
import styles from './MountItems.css';
|
||||||
import Modal from '../../components/UI/Modal/Modal';
|
import Modal from '../../components/UI/Modal/Modal';
|
||||||
import MountItem from '../../components/MountItem/MountItem';
|
import MountItem from '../../components/MountItem/MountItem';
|
||||||
import RootElem from '../../hoc/RootElem/RootElem';
|
|
||||||
|
|
||||||
const Constants = require('../../constants');
|
const Constants = require('../../constants');
|
||||||
|
|
||||||
@@ -18,6 +17,7 @@ if (!process.versions.hasOwnProperty('electron')) {
|
|||||||
class MountItems extends Component {
|
class MountItems extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
this.state[provider] = {
|
this.state[provider] = {
|
||||||
AllowMount: false,
|
AllowMount: false,
|
||||||
@@ -25,6 +25,7 @@ class MountItems extends Component {
|
|||||||
Mounted: false,
|
Mounted: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
ipcRenderer.on(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
|
ipcRenderer.on(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
|
||||||
ipcRenderer.on(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
|
ipcRenderer.on(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
|
||||||
@@ -72,18 +73,19 @@ class MountItems extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
detectMounts = ()=> {
|
detectMounts = ()=> {
|
||||||
this.props.mountsBusy(true);
|
if (!this.state.DisplayRetry) {
|
||||||
ipcRenderer.send(Constants.IPC_Detect_Mounts, {
|
this.props.mountsBusy(true);
|
||||||
Directory: this.props.directory,
|
ipcRenderer.send(Constants.IPC_Detect_Mounts, {
|
||||||
Version: this.props.version,
|
Directory: this.props.directory,
|
||||||
});
|
Version: this.props.version,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMountLocationChanged = (storageType, value) => {
|
handleMountLocationChanged = (storageType, value) => {
|
||||||
if (this.props.platform === 'win32') {
|
if (this.props.platform === 'win32') {
|
||||||
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
this.props.changed(storageType, this.state[storageType].DriveLetters[value]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.props.changed(storageType, value);
|
this.props.changed(storageType, value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -91,54 +93,52 @@ class MountItems extends Component {
|
|||||||
handleMountUnMount = (storageType, mount, location) => {
|
handleMountUnMount = (storageType, mount, location) => {
|
||||||
if (!location || (location.trim().length === 0)) {
|
if (!location || (location.trim().length === 0)) {
|
||||||
this.props.errorHandler('Mount location is not set');
|
this.props.errorHandler('Mount location is not set');
|
||||||
} else {
|
} else if (ipcRenderer) {
|
||||||
if (ipcRenderer) {
|
let allowAction = true;
|
||||||
let allowAction = true;
|
if (mount && (this.props.platform !== 'win32')) {
|
||||||
if (mount && (this.props.platform !== 'win32')) {
|
const result = ipcRenderer.sendSync(Constants.IPC_Check_Mount_Location, {
|
||||||
const result = ipcRenderer.sendSync(Constants.IPC_Check_Mount_Location, {
|
Location: location,
|
||||||
Location: location,
|
});
|
||||||
});
|
if (!result.Success) {
|
||||||
if (!result.Success) {
|
allowAction = false;
|
||||||
allowAction = false;
|
this.props.errorHandler(result.Error.toString());
|
||||||
this.props.errorHandler(result.Error.toString());
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowAction) {
|
||||||
|
const storageState = {
|
||||||
|
...this.state[storageType],
|
||||||
|
AllowMount: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.props.mountsBusy(true);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
[storageType]: storageState,
|
||||||
|
}, () => {
|
||||||
|
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,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onDetectMountsReply = (event, arg) => {
|
onDetectMountsReply = (event, arg) => {
|
||||||
if (arg.data.Success) {
|
if (!this.state.DisplayRetry && arg.data.Success) {
|
||||||
let state = {};
|
let state = {};
|
||||||
let mountsBusy = false;
|
let mountsBusy = false;
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
@@ -199,7 +199,13 @@ class MountItems extends Component {
|
|||||||
retryItems[storageType] = {
|
retryItems[storageType] = {
|
||||||
RetrySeconds: 10,
|
RetrySeconds: 10,
|
||||||
};
|
};
|
||||||
|
const storageState = {
|
||||||
|
...this.state[arg.data.StorageType],
|
||||||
|
AllowMount: false,
|
||||||
|
Mounted: false,
|
||||||
|
};
|
||||||
this.setState({
|
this.setState({
|
||||||
|
[storageType]: storageState,
|
||||||
DisplayRetry: true,
|
DisplayRetry: true,
|
||||||
RetryItems: retryItems,
|
RetryItems: retryItems,
|
||||||
}, () => {
|
}, () => {
|
||||||
@@ -252,21 +258,18 @@ class MountItems extends Component {
|
|||||||
for (const storageType in this.state.RetryItems) {
|
for (const storageType in this.state.RetryItems) {
|
||||||
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
if (this.state.RetryItems.hasOwnProperty(storageType)) {
|
||||||
retryListCount++;
|
retryListCount++;
|
||||||
retryList.push((
|
retryList.push(<Button
|
||||||
<RootElem key={retryList.length}>
|
clicked={()=>this.cancelRetryMount(storageType, ()=> this.detectMounts())}
|
||||||
<p>Retrying {storageType} in {this.state.RetryItems[storageType].RetrySeconds}(s)</p>
|
key={'b' + retryListCount}>Cancel {storageType} Auto-Retry ({this.state.RetryItems[storageType].RetrySeconds}s)]</Button>);
|
||||||
<Button clicked={()=>this.cancelRetryMount(storageType, ()=> this.detectMounts())}>Cancel {storageType}</Button>
|
|
||||||
</RootElem>
|
|
||||||
));
|
|
||||||
if (retryListCount < Object.keys(this.state.RetryItems).length) {
|
if (retryListCount < Object.keys(this.state.RetryItems).length) {
|
||||||
retryList.push(<div style={{paddingTop: '8px'}} key={'b'+retryList.length}/>);
|
retryList.push(<div style={{paddingTop: '8px'}} key={'d' + retryListCount}/>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retryDisplay = (
|
retryDisplay = (
|
||||||
<Modal>
|
<Modal>
|
||||||
<Box dxStyle={{padding: '8px', minWidth: '60vw'}}>
|
<Box dxStyle={{padding: '8px', minWidth: '70vw'}}>
|
||||||
<h1 style={{textAlign: 'center'}}>Mount Failed</h1>
|
<h1 style={{textAlign: 'center'}}>Mount Failed</h1>
|
||||||
{retryList}
|
{retryList}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user