#24: Add retry logic to version check
This commit is contained in:
@@ -19,7 +19,7 @@ const mapDispatchToProps = dispatch => {
|
|||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||||
return (
|
return (
|
||||||
<Box dxStyle={{padding: '8px'}}>
|
<Box dxDark dxStyle={{padding: '8px'}}>
|
||||||
<h1 className={'ErrorDetailsHeading'}>Application Error</h1>
|
<h1 className={'ErrorDetailsHeading'}>Application Error</h1>
|
||||||
<div className={'ErrorDetailsContent'}>
|
<div className={'ErrorDetailsContent'}>
|
||||||
<p>{props.ErrorMessage}</p>
|
<p>{props.ErrorMessage}</p>
|
||||||
|
|||||||
@@ -78,6 +78,46 @@ class MountItems extends IPCContainer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
displayRetryMount = (provider, mountLocation, msg) => {
|
||||||
|
if (!this.state.RetryItems[provider]) {
|
||||||
|
let retryItems = {
|
||||||
|
...this.state.RetryItems
|
||||||
|
};
|
||||||
|
retryItems[provider] = {
|
||||||
|
RetrySeconds: 10,
|
||||||
|
RetryMessage: msg ? msg.toString() : null,
|
||||||
|
};
|
||||||
|
const mountState = {
|
||||||
|
AllowMount: false,
|
||||||
|
Mounted: false,
|
||||||
|
};
|
||||||
|
this.props.setMountState(provider, mountState);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
DisplayRetry: true,
|
||||||
|
RetryItems: retryItems,
|
||||||
|
}, () => {
|
||||||
|
this.sendRequest(Constants.IPC_Show_Window);
|
||||||
|
this.retryIntervals[provider] = setInterval(() => {
|
||||||
|
let retryItems = {
|
||||||
|
...this.state.RetryItems,
|
||||||
|
};
|
||||||
|
const retrySeconds = retryItems[provider].RetrySeconds - 1;
|
||||||
|
if (retrySeconds === 0) {
|
||||||
|
this.cancelRetryMount(provider, () => {
|
||||||
|
this.handleMountUnMount(provider, true, mountLocation);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
retryItems[provider].RetrySeconds = retrySeconds;
|
||||||
|
this.setState({
|
||||||
|
RetryItems: retryItems,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
handleBrowseLocation = (provider, location) => {
|
handleBrowseLocation = (provider, location) => {
|
||||||
location = this.sendSyncRequest(Constants.IPC_Browse_Directory, {
|
location = this.sendSyncRequest(Constants.IPC_Browse_Directory, {
|
||||||
Title: provider + ' Mount Location',
|
Title: provider + ' Mount Location',
|
||||||
@@ -123,17 +163,17 @@ class MountItems extends IPCContainer {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
allowAction = false;
|
allowAction = false;
|
||||||
if (result.Code === (new Uint32Array([-1]))[0]) {
|
if ((result.Code === new Uint32Array([-1])[0]) || (result.Code === new Uint8Array([-1])[0])) {
|
||||||
this.props.notifyError('Failed to connect to ' + provider + ' daemon');
|
this.displayRetryMount(provider, location, 'Failed to connect to ' + provider + ' daemon');
|
||||||
} else if (result.Code === (new Uint32Array([-3]))[0]) {
|
} else if ((result.Code === new Uint32Array([-3])[0]) || (result.Code === new Uint8Array([-3])[0])) {
|
||||||
this.props.notifyError('Incompatible ' + provider + ' daemon. Please upgrade ' + provider);
|
this.displayRetryMount(provider, location, 'Incompatible ' + provider + ' daemon. Please upgrade ' + provider);
|
||||||
} else {
|
} else {
|
||||||
this.props.notifyError('Version check failed: ' + result.Error);
|
this.displayRetryMount(provider, location, 'Version check failed: ' + result.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
allowAction = false;
|
allowAction = false;
|
||||||
this.props.notifyError(result.Error.toString());
|
this.displayRetryMount(provider, location, 'Version check failed: ' + result.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,43 +253,7 @@ class MountItems extends IPCContainer {
|
|||||||
|
|
||||||
onUnmountDriveReply = (event, arg) => {
|
onUnmountDriveReply = (event, arg) => {
|
||||||
if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props.ProviderState[arg.data.Provider].AutoRestart) {
|
if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props.ProviderState[arg.data.Provider].AutoRestart) {
|
||||||
const provider = arg.data.Provider;
|
this.displayRetryMount(arg.data.Provider, arg.data.Location);
|
||||||
if (!this.state.RetryItems[provider]) {
|
|
||||||
let retryItems = {
|
|
||||||
...this.state.RetryItems
|
|
||||||
};
|
|
||||||
retryItems[provider] = {
|
|
||||||
RetrySeconds: 10,
|
|
||||||
};
|
|
||||||
const mountState = {
|
|
||||||
AllowMount: false,
|
|
||||||
Mounted: false,
|
|
||||||
};
|
|
||||||
this.props.setMountState(provider, mountState);
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
DisplayRetry: true,
|
|
||||||
RetryItems: retryItems,
|
|
||||||
}, () => {
|
|
||||||
this.sendRequest(Constants.IPC_Show_Window);
|
|
||||||
this.retryIntervals[provider] = setInterval(() => {
|
|
||||||
let retryItems = {
|
|
||||||
...this.state.RetryItems,
|
|
||||||
};
|
|
||||||
const retrySeconds = retryItems[provider].RetrySeconds - 1;
|
|
||||||
if (retrySeconds === 0) {
|
|
||||||
this.cancelRetryMount(provider, () => {
|
|
||||||
this.handleMountUnMount(provider, true, arg.data.Location);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
retryItems[provider].RetrySeconds = retrySeconds;
|
|
||||||
this.setState({
|
|
||||||
RetryItems: retryItems,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},1000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.detectMounts();
|
this.detectMounts();
|
||||||
}
|
}
|
||||||
@@ -263,6 +267,9 @@ class MountItems extends IPCContainer {
|
|||||||
for (const provider in this.state.RetryItems) {
|
for (const provider in this.state.RetryItems) {
|
||||||
if (this.state.RetryItems.hasOwnProperty(provider)) {
|
if (this.state.RetryItems.hasOwnProperty(provider)) {
|
||||||
retryListCount++;
|
retryListCount++;
|
||||||
|
if (this.state.RetryItems[provider].RetryMessage) {
|
||||||
|
retryList.push(<p key={'p' + retryListCount}>{this.state.RetryItems[provider].RetryMessage}</p>);
|
||||||
|
}
|
||||||
retryList.push(<Button
|
retryList.push(<Button
|
||||||
clicked={()=>this.cancelRetryMount(provider, ()=> this.detectMounts())}
|
clicked={()=>this.cancelRetryMount(provider, ()=> this.detectMounts())}
|
||||||
key={'b' + retryListCount}>Cancel {provider} Remount ({this.state.RetryItems[provider].RetrySeconds}s)</Button>);
|
key={'b' + retryListCount}>Cancel {provider} Remount ({this.state.RetryItems[provider].RetrySeconds}s)</Button>);
|
||||||
@@ -274,7 +281,7 @@ class MountItems extends IPCContainer {
|
|||||||
|
|
||||||
retryDisplay = (
|
retryDisplay = (
|
||||||
<Modal>
|
<Modal>
|
||||||
<Box dxStyle={{padding: '8px', minWidth: '70vw'}}>
|
<Box dxDark dxStyle={{padding: '8px', minWidth: '70vw'}}>
|
||||||
<h1 style={{textAlign: 'center', paddingBottom: '8px', color: 'var(--text_color_error)'}}>Mount Failed</h1>
|
<h1 style={{textAlign: 'center', paddingBottom: '8px', color: 'var(--text_color_error)'}}>Mount Failed</h1>
|
||||||
{retryList}
|
{retryList}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user