Auto-restart on unexpected failure
This commit is contained in:
14
electron.js
14
electron.js
@@ -18,6 +18,7 @@ let mainContextWindow;
|
|||||||
let mainWindow;
|
let mainWindow;
|
||||||
let mainWindowTray;
|
let mainWindowTray;
|
||||||
let mountedPIDs = [];
|
let mountedPIDs = [];
|
||||||
|
let expectedUnmount = {};
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
@@ -260,6 +261,15 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
siaPrimeLocation = siaPrimeLocation.toUpperCase();
|
siaPrimeLocation = siaPrimeLocation.toUpperCase();
|
||||||
grabDriveLetters(hsLocation, siaLocation, siaPrimeLocation);
|
grabDriveLetters(hsLocation, siaLocation, siaPrimeLocation);
|
||||||
}
|
}
|
||||||
|
if (results.Hyperspace.PID !== -1) {
|
||||||
|
expectedUnmount['Hyperspace'] = false;
|
||||||
|
}
|
||||||
|
if (results.Sia.PID !== -1) {
|
||||||
|
expectedUnmount['Sia'] = false;
|
||||||
|
}
|
||||||
|
if (results.SiaPrime.PID !== -1) {
|
||||||
|
expectedUnmount['SiaPrime'] = false;
|
||||||
|
}
|
||||||
setImage(hsLocation, siaLocation, siaPrimeLocation);
|
setImage(hsLocation, siaLocation, siaPrimeLocation);
|
||||||
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
||||||
DriveLetters: driveLetters,
|
DriveLetters: driveLetters,
|
||||||
@@ -417,10 +427,13 @@ ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
||||||
|
expectedUnmount[data.StorageType] = false;
|
||||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
const errorHandler = (pid, error) => {
|
const errorHandler = (pid, error) => {
|
||||||
mountedPIDs.splice(mountedPIDs.indexOf(pid), 1);
|
mountedPIDs.splice(mountedPIDs.indexOf(pid), 1);
|
||||||
standardIPCReply(event, Constants.IPC_Unmount_Drive_Reply, {
|
standardIPCReply(event, Constants.IPC_Unmount_Drive_Reply, {
|
||||||
|
Expected: expectedUnmount[data.StorageType],
|
||||||
|
Location: data.Location,
|
||||||
PID: -1,
|
PID: -1,
|
||||||
StorageType: data.StorageType,
|
StorageType: data.StorageType,
|
||||||
}, error || Error(data.StorageType + ' Unmounted'));
|
}, error || Error(data.StorageType + ' Unmounted'));
|
||||||
@@ -473,6 +486,7 @@ ipcMain.on(Constants.IPC_Shutdown, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
||||||
|
expectedUnmount[data.StorageType] = true;
|
||||||
helpers
|
helpers
|
||||||
.stopProcessByPID(data.PID)
|
.stopProcessByPID(data.PID)
|
||||||
.then((pid)=> {
|
.then((pid)=> {
|
||||||
|
|||||||
60
src/App.js
60
src/App.js
@@ -62,6 +62,7 @@ class App extends Component {
|
|||||||
ExtractActive: false,
|
ExtractActive: false,
|
||||||
Hyperspace: {
|
Hyperspace: {
|
||||||
AutoMount: false,
|
AutoMount: false,
|
||||||
|
AutoRestart: false,
|
||||||
MountLocation: '',
|
MountLocation: '',
|
||||||
},
|
},
|
||||||
LocationsLookup: {},
|
LocationsLookup: {},
|
||||||
@@ -78,10 +79,12 @@ class App extends Component {
|
|||||||
InstalledVersion: 'none',
|
InstalledVersion: 'none',
|
||||||
Sia: {
|
Sia: {
|
||||||
AutoMount: false,
|
AutoMount: false,
|
||||||
|
AutoRestart: false,
|
||||||
MountLocation: '',
|
MountLocation: '',
|
||||||
},
|
},
|
||||||
SiaPrime: {
|
SiaPrime: {
|
||||||
AutoMount: false,
|
AutoMount: false,
|
||||||
|
AutoRestart: false,
|
||||||
MountLocation: '',
|
MountLocation: '',
|
||||||
},
|
},
|
||||||
UpgradeAvailable: false,
|
UpgradeAvailable: false,
|
||||||
@@ -180,27 +183,68 @@ class App extends Component {
|
|||||||
...this.state.Hyperspace
|
...this.state.Hyperspace
|
||||||
};
|
};
|
||||||
|
|
||||||
this.saveState(this.state.Release, this.state.Version, sia, hyperspace, siaPrime);
|
|
||||||
|
|
||||||
if (storageType === 'Hyperspace') {
|
if (storageType === 'Hyperspace') {
|
||||||
hyperspace.AutoMount = e.target.checked;
|
hyperspace.AutoMount = e.target.checked;
|
||||||
this.setState({
|
this.setState({
|
||||||
Hyperspace: hyperspace,
|
Hyperspace: hyperspace,
|
||||||
|
}, ()=> {
|
||||||
|
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||||
});
|
});
|
||||||
} else if (storageType === 'Sia') {
|
} else if (storageType === 'Sia') {
|
||||||
sia.AutoMount = e.target.checked;
|
sia.AutoMount = e.target.checked;
|
||||||
this.setState({
|
this.setState({
|
||||||
Sia: sia,
|
Sia: sia,
|
||||||
|
}, ()=> {
|
||||||
|
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||||
});
|
});
|
||||||
} else if (storageType === 'SiaPrime') {
|
} else if (storageType === 'SiaPrime') {
|
||||||
siaPrime.AutoMount = e.target.checked;
|
siaPrime.AutoMount = e.target.checked;
|
||||||
this.setState({
|
this.setState({
|
||||||
SiaPrime: siaPrime,
|
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) => {
|
handleConfigClicked = (storageType) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
ConfigStorageType: storageType,
|
ConfigStorageType: storageType,
|
||||||
@@ -426,16 +470,25 @@ class App extends Component {
|
|||||||
if (hyperspace.AutoMount === undefined) {
|
if (hyperspace.AutoMount === undefined) {
|
||||||
hyperspace['AutoMount'] = false;
|
hyperspace['AutoMount'] = false;
|
||||||
}
|
}
|
||||||
|
if (hyperspace.AutoRestart === undefined) {
|
||||||
|
hyperspace['AutoRestart'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
let sia = arg.data.Sia || this.state.Sia;
|
let sia = arg.data.Sia || this.state.Sia;
|
||||||
if (sia.AutoMount === undefined) {
|
if (sia.AutoMount === undefined) {
|
||||||
sia['AutoMount'] = false;
|
sia['AutoMount'] = false;
|
||||||
}
|
}
|
||||||
|
if (sia.AutoRestart === undefined) {
|
||||||
|
sia['AutoRestart'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
let siaPrime = arg.data.SiaPrime || this.state.SiaPrime;
|
let siaPrime = arg.data.SiaPrime || this.state.SiaPrime;
|
||||||
if (siaPrime.AutoMount === undefined) {
|
if (siaPrime.AutoMount === undefined) {
|
||||||
siaPrime['AutoMount'] = false;
|
siaPrime['AutoMount'] = false;
|
||||||
}
|
}
|
||||||
|
if (siaPrime.AutoRestart === undefined) {
|
||||||
|
siaPrime['AutoRestart'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
Hyperspace: hyperspace,
|
Hyperspace: hyperspace,
|
||||||
@@ -683,10 +736,11 @@ class App extends Component {
|
|||||||
if (allowMount) {
|
if (allowMount) {
|
||||||
mainContent.push((
|
mainContent.push((
|
||||||
<div key={'md_' + key++}
|
<div key={'md_' + key++}
|
||||||
style={{height: '66%'}}>
|
style={{height: '69%'}}>
|
||||||
<MountItems allowConfig={allowConfig}
|
<MountItems allowConfig={allowConfig}
|
||||||
autoMountChanged={this.handleAutoMountChanged}
|
autoMountChanged={this.handleAutoMountChanged}
|
||||||
autoMountProcessed={this.notifyAutoMountProcessed}
|
autoMountProcessed={this.notifyAutoMountProcessed}
|
||||||
|
autoRestartChanged={this.handleAutoRestartChanged}
|
||||||
changed={this.handleMountLocationChanged}
|
changed={this.handleMountLocationChanged}
|
||||||
configClicked={this.handleConfigClicked}
|
configClicked={this.handleConfigClicked}
|
||||||
directory={Constants.DATA_LOCATIONS[this.props.platform]}
|
directory={Constants.DATA_LOCATIONS[this.props.platform]}
|
||||||
|
|||||||
@@ -79,6 +79,17 @@ export default CSSModules((props) => {
|
|||||||
</RootElem>
|
</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 (
|
return (
|
||||||
<Grid>
|
<Grid>
|
||||||
{configButton}
|
{configButton}
|
||||||
@@ -90,6 +101,7 @@ export default CSSModules((props) => {
|
|||||||
{inputControl}
|
{inputControl}
|
||||||
{actionsDisplay}
|
{actionsDisplay}
|
||||||
{autoMountControl}
|
{autoMountControl}
|
||||||
|
{autoRestartControl}
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}, styles, {allowMultiple: true});
|
}, styles, {allowMultiple: true});
|
||||||
@@ -177,7 +177,12 @@ class MountItems extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onUnmountDriveReply = (event, arg) => {
|
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 = ()=> {
|
performAutoMount = ()=> {
|
||||||
@@ -208,6 +213,8 @@ class MountItems extends Component {
|
|||||||
allowMount={this.state.Hyperspace.AllowMount}
|
allowMount={this.state.Hyperspace.AllowMount}
|
||||||
autoMount={this.props.hyperspace.AutoMount}
|
autoMount={this.props.hyperspace.AutoMount}
|
||||||
autoMountChanged={(e)=>this.props.autoMountChanged('Hyperspace', e)}
|
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)}
|
changed={(e) => this.handleMountLocationChanged('Hyperspace', e.target.value)}
|
||||||
clicked={this.handleMountUnMount}
|
clicked={this.handleMountUnMount}
|
||||||
configClicked={()=>this.props.configClicked('Hyperspace')}
|
configClicked={()=>this.props.configClicked('Hyperspace')}
|
||||||
@@ -222,6 +229,8 @@ class MountItems extends Component {
|
|||||||
allowMount={this.state.Sia.AllowMount}
|
allowMount={this.state.Sia.AllowMount}
|
||||||
autoMount={this.props.sia.AutoMount}
|
autoMount={this.props.sia.AutoMount}
|
||||||
autoMountChanged={(e)=>this.props.autoMountChanged('Sia', e)}
|
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)}
|
changed={(e) => this.handleMountLocationChanged('Sia', e.target.value)}
|
||||||
clicked={this.handleMountUnMount}
|
clicked={this.handleMountUnMount}
|
||||||
configClicked={()=>this.props.configClicked('Sia')}
|
configClicked={()=>this.props.configClicked('Sia')}
|
||||||
@@ -233,9 +242,11 @@ class MountItems extends Component {
|
|||||||
title={'Sia'}/>
|
title={'Sia'}/>
|
||||||
<div style={{paddingTop: '12px'}}/>
|
<div style={{paddingTop: '12px'}}/>
|
||||||
<MountItem allowConfig={this.props.allowConfig}
|
<MountItem allowConfig={this.props.allowConfig}
|
||||||
allowMount={this.state.Sia.AllowMount}
|
allowMount={this.state.SiaPrime.AllowMount}
|
||||||
autoMount={this.props.siaprime.AutoMount}
|
autoMount={this.props.siaprime.AutoMount}
|
||||||
autoMountChanged={(e)=>this.props.autoMountChanged('SiaPrime', e)}
|
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)}
|
changed={(e) => this.handleMountLocationChanged('SiaPrime', e.target.value)}
|
||||||
clicked={this.handleMountUnMount}
|
clicked={this.handleMountUnMount}
|
||||||
configClicked={()=>this.props.configClicked('SiaPrime')}
|
configClicked={()=>this.props.configClicked('SiaPrime')}
|
||||||
|
|||||||
Reference in New Issue
Block a user