Auto-restart on unexpected failure
This commit is contained in:
60
src/App.js
60
src/App.js
@@ -62,6 +62,7 @@ class App extends Component {
|
||||
ExtractActive: false,
|
||||
Hyperspace: {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
},
|
||||
LocationsLookup: {},
|
||||
@@ -78,10 +79,12 @@ class App extends Component {
|
||||
InstalledVersion: 'none',
|
||||
Sia: {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
},
|
||||
SiaPrime: {
|
||||
AutoMount: false,
|
||||
AutoRestart: false,
|
||||
MountLocation: '',
|
||||
},
|
||||
UpgradeAvailable: false,
|
||||
@@ -180,27 +183,68 @@ class App extends Component {
|
||||
...this.state.Hyperspace
|
||||
};
|
||||
|
||||
this.saveState(this.state.Release, this.state.Version, sia, hyperspace, siaPrime);
|
||||
|
||||
if (storageType === 'Hyperspace') {
|
||||
hyperspace.AutoMount = e.target.checked;
|
||||
this.setState({
|
||||
Hyperspace: hyperspace,
|
||||
}, ()=> {
|
||||
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||
});
|
||||
} else if (storageType === 'Sia') {
|
||||
sia.AutoMount = e.target.checked;
|
||||
this.setState({
|
||||
Sia: sia,
|
||||
}, ()=> {
|
||||
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||
});
|
||||
} else if (storageType === 'SiaPrime') {
|
||||
siaPrime.AutoMount = e.target.checked;
|
||||
this.setState({
|
||||
SiaPrime: siaPrime,
|
||||
}, ()=> {
|
||||
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
handleAutoRestartChanged = (storageType, e) => {
|
||||
let sia = {
|
||||
...this.state.Sia
|
||||
};
|
||||
|
||||
let siaPrime = {
|
||||
...this.state.SiaPrime
|
||||
};
|
||||
|
||||
let hyperspace = {
|
||||
...this.state.Hyperspace
|
||||
};
|
||||
|
||||
if (storageType === 'Hyperspace') {
|
||||
hyperspace.AutoRestart = e.target.checked;
|
||||
this.setState({
|
||||
Hyperspace: hyperspace,
|
||||
}, ()=> {
|
||||
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||
});
|
||||
} else if (storageType === 'Sia') {
|
||||
sia.AutoRestart = e.target.checked;
|
||||
this.setState({
|
||||
Sia: sia,
|
||||
}, ()=> {
|
||||
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||
});
|
||||
} else if (storageType === 'SiaPrime') {
|
||||
siaPrime.AutoRestart = e.target.checked;
|
||||
this.setState({
|
||||
SiaPrime: siaPrime,
|
||||
}, ()=> {
|
||||
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
handleConfigClicked = (storageType) => {
|
||||
this.setState({
|
||||
ConfigStorageType: storageType,
|
||||
@@ -426,16 +470,25 @@ class App extends Component {
|
||||
if (hyperspace.AutoMount === undefined) {
|
||||
hyperspace['AutoMount'] = false;
|
||||
}
|
||||
if (hyperspace.AutoRestart === undefined) {
|
||||
hyperspace['AutoRestart'] = false;
|
||||
}
|
||||
|
||||
let sia = arg.data.Sia || this.state.Sia;
|
||||
if (sia.AutoMount === undefined) {
|
||||
sia['AutoMount'] = false;
|
||||
}
|
||||
if (sia.AutoRestart === undefined) {
|
||||
sia['AutoRestart'] = false;
|
||||
}
|
||||
|
||||
let siaPrime = arg.data.SiaPrime || this.state.SiaPrime;
|
||||
if (siaPrime.AutoMount === undefined) {
|
||||
siaPrime['AutoMount'] = false;
|
||||
}
|
||||
if (siaPrime.AutoRestart === undefined) {
|
||||
siaPrime['AutoRestart'] = false;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
Hyperspace: hyperspace,
|
||||
@@ -683,10 +736,11 @@ class App extends Component {
|
||||
if (allowMount) {
|
||||
mainContent.push((
|
||||
<div key={'md_' + key++}
|
||||
style={{height: '66%'}}>
|
||||
style={{height: '69%'}}>
|
||||
<MountItems allowConfig={allowConfig}
|
||||
autoMountChanged={this.handleAutoMountChanged}
|
||||
autoMountProcessed={this.notifyAutoMountProcessed}
|
||||
autoRestartChanged={this.handleAutoRestartChanged}
|
||||
changed={this.handleMountLocationChanged}
|
||||
configClicked={this.handleConfigClicked}
|
||||
directory={Constants.DATA_LOCATIONS[this.props.platform]}
|
||||
|
||||
@@ -79,6 +79,17 @@ export default CSSModules((props) => {
|
||||
</RootElem>
|
||||
);
|
||||
|
||||
const autoRestartControl = (
|
||||
<RootElem col={inputColumnSpan + 23 + 25}
|
||||
colSpan={24}
|
||||
row={secondRow}
|
||||
rowSpan={7}>
|
||||
<input checked={props.autoRestart}
|
||||
onChange={props.autoRestartChanged}
|
||||
type='checkbox'/>Restart
|
||||
</RootElem>
|
||||
);
|
||||
|
||||
return (
|
||||
<Grid>
|
||||
{configButton}
|
||||
@@ -90,6 +101,7 @@ export default CSSModules((props) => {
|
||||
{inputControl}
|
||||
{actionsDisplay}
|
||||
{autoMountControl}
|
||||
{autoRestartControl}
|
||||
</Grid>
|
||||
);
|
||||
}, styles, {allowMultiple: true});
|
||||
@@ -177,7 +177,12 @@ class MountItems extends Component {
|
||||
};
|
||||
|
||||
onUnmountDriveReply = (event, arg) => {
|
||||
this.detectMounts();
|
||||
console.log(arg);
|
||||
if ((this.props.platform === 'win32') && arg && arg.data && !arg.data.Expected && arg.data.Location && this.props[arg.data.StorageType.toLowerCase()].AutoRestart) {
|
||||
this.handleMountUnMount(arg.data.StorageType, true, arg.data.Location)
|
||||
} else {
|
||||
this.detectMounts();
|
||||
}
|
||||
};
|
||||
|
||||
performAutoMount = ()=> {
|
||||
@@ -208,6 +213,8 @@ class MountItems extends Component {
|
||||
allowMount={this.state.Hyperspace.AllowMount}
|
||||
autoMount={this.props.hyperspace.AutoMount}
|
||||
autoMountChanged={(e)=>this.props.autoMountChanged('Hyperspace', e)}
|
||||
autoRestart={this.props.hyperspace.AutoRestart}
|
||||
autoRestartChanged={(e)=>this.props.autoRestartChanged('Hyperspace', e)}
|
||||
changed={(e) => this.handleMountLocationChanged('Hyperspace', e.target.value)}
|
||||
clicked={this.handleMountUnMount}
|
||||
configClicked={()=>this.props.configClicked('Hyperspace')}
|
||||
@@ -222,6 +229,8 @@ class MountItems extends Component {
|
||||
allowMount={this.state.Sia.AllowMount}
|
||||
autoMount={this.props.sia.AutoMount}
|
||||
autoMountChanged={(e)=>this.props.autoMountChanged('Sia', e)}
|
||||
autoRestart={this.props.sia.AutoRestart}
|
||||
autoRestartChanged={(e)=>this.props.autoRestartChanged('Sia', e)}
|
||||
changed={(e) => this.handleMountLocationChanged('Sia', e.target.value)}
|
||||
clicked={this.handleMountUnMount}
|
||||
configClicked={()=>this.props.configClicked('Sia')}
|
||||
@@ -233,9 +242,11 @@ class MountItems extends Component {
|
||||
title={'Sia'}/>
|
||||
<div style={{paddingTop: '12px'}}/>
|
||||
<MountItem allowConfig={this.props.allowConfig}
|
||||
allowMount={this.state.Sia.AllowMount}
|
||||
allowMount={this.state.SiaPrime.AllowMount}
|
||||
autoMount={this.props.siaprime.AutoMount}
|
||||
autoMountChanged={(e)=>this.props.autoMountChanged('SiaPrime', e)}
|
||||
autoRestart={this.props.siaprime.AutoRestart}
|
||||
autoRestartChanged={(e)=>this.props.autoRestartChanged('SiaPrime', e)}
|
||||
changed={(e) => this.handleMountLocationChanged('SiaPrime', e.target.value)}
|
||||
clicked={this.handleMountUnMount}
|
||||
configClicked={()=>this.props.configClicked('SiaPrime')}
|
||||
|
||||
Reference in New Issue
Block a user