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 mainWindowTray;
|
||||
let mountedPIDs = [];
|
||||
let expectedUnmount = {};
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
@@ -260,6 +261,15 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
||||
siaPrimeLocation = siaPrimeLocation.toUpperCase();
|
||||
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);
|
||||
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
||||
DriveLetters: driveLetters,
|
||||
@@ -417,10 +427,13 @@ ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
|
||||
});
|
||||
|
||||
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
||||
expectedUnmount[data.StorageType] = false;
|
||||
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||
const errorHandler = (pid, error) => {
|
||||
mountedPIDs.splice(mountedPIDs.indexOf(pid), 1);
|
||||
standardIPCReply(event, Constants.IPC_Unmount_Drive_Reply, {
|
||||
Expected: expectedUnmount[data.StorageType],
|
||||
Location: data.Location,
|
||||
PID: -1,
|
||||
StorageType: data.StorageType,
|
||||
}, error || Error(data.StorageType + ' Unmounted'));
|
||||
@@ -473,6 +486,7 @@ ipcMain.on(Constants.IPC_Shutdown, () => {
|
||||
});
|
||||
|
||||
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
|
||||
expectedUnmount[data.StorageType] = true;
|
||||
helpers
|
||||
.stopProcessByPID(data.PID)
|
||||
.then((pid)=> {
|
||||
|
||||
Reference in New Issue
Block a user