Redux changes and refactoring

This commit is contained in:
Scott E. Graves
2019-06-06 15:52:56 -05:00
parent 6502657e3c
commit 0bbfddc17c
9 changed files with 233 additions and 211 deletions

View File

@@ -119,7 +119,7 @@ function createWindow() {
// Unmount all items
for (const i in mountedLocations) {
const data = mountedData[mountedLocations[i]];
helpers.stopMountProcessSync(data.Version, data.StorageType);
helpers.stopMountProcessSync(data.Version, data.Provider);
}
mountedLocations = [];
@@ -205,10 +205,10 @@ if (!instanceLock) {
});
}
const clearManualMountDetection = (storageType) => {
if (manualMountDetection[storageType]) {
clearInterval(manualMountDetection[storageType]);
delete manualMountDetection[storageType];
const clearManualMountDetection = (provider) => {
if (manualMountDetection[provider]) {
clearInterval(manualMountDetection[provider]);
delete manualMountDetection[provider];
}
};
@@ -223,25 +223,25 @@ const loadUiSettings = () => {
}
};
const monitorMount = (sender, storageType, version, pid, location) => {
manualMountDetection[storageType] = setInterval(() => {
const monitorMount = (sender, provider, version, pid, location) => {
manualMountDetection[provider] = setInterval(() => {
helpers
.detectRepertoryMounts(version)
.then(result => {
if (result[storageType].PID !== pid) {
if (result[storageType].PID === -1) {
clearManualMountDetection(storageType);
if (result[provider].PID !== pid) {
if (result[provider].PID === -1) {
clearManualMountDetection(provider);
sender.send(Constants.IPC_Unmount_Drive_Reply, {
data: {
Expected: expectedUnmount[storageType],
Expected: expectedUnmount[provider],
Location: location,
StorageType: storageType,
Error: Error(storageType + ' Unmounted').toString(),
Provider: provider,
Error: Error(provider + ' Unmounted').toString(),
Success: false,
}
});
} else {
pid = result[storageType].PID;
pid = result[provider].PID;
}
}
})
@@ -289,7 +289,7 @@ ipcMain.on(Constants.IPC_Browse_Directory + '_sync', (event, data) => {
ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
helpers
.checkDaemonVersion(data.Version, data.StorageType)
.checkDaemonVersion(data.Version, data.Provider)
.then(code => {
standardIPCReply(event, Constants.IPC_Check_Daemon_Version_Reply, {
Valid: (code === 0),
@@ -304,7 +304,7 @@ ipcMain.on(Constants.IPC_Check_Daemon_Version, (event, data) => {
ipcMain.on(Constants.IPC_Check_Daemon_Version + '_sync', (event, data) => {
helpers
.checkDaemonVersion(data.Version, data.StorageType)
.checkDaemonVersion(data.Version, data.Provider)
.then(code => {
event.returnValue = {
data: {
@@ -593,7 +593,7 @@ ipcMain.on(Constants.IPC_Extract_Release, (event, data) => {
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
helpers
.getConfig(data.Version, data.StorageType)
.getConfig(data.Version, data.Provider)
.then((data) => {
if (data.Code === 0) {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
@@ -610,7 +610,7 @@ ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
helpers
.getConfigTemplate(data.Version, data.StorageType)
.getConfigTemplate(data.Version, data.Provider)
.then((data) => {
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
Template: data,
@@ -796,15 +796,15 @@ ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
});
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
expectedUnmount[data.StorageType] = false;
expectedUnmount[data.Provider] = false;
if (mountedLocations.indexOf(data.Location) !== -1) {
console.log(data.StorageType + ' already mounted: ' + data.Location);
console.log(data.Provider + ' already mounted: ' + data.Location);
} else {
mountedLocations.push(data.Location);
mountedData[data.Location] = {
Version: data.Version,
StorageType: data.StorageType,
Provider: data.Provider,
};
const errorHandler = (pid, error) => {
if (mountedLocations.indexOf(data.Location) !== -1) {
@@ -813,18 +813,18 @@ ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
}
standardIPCReply(event, Constants.IPC_Unmount_Drive_Reply, {
Expected: expectedUnmount[data.StorageType],
Expected: expectedUnmount[data.Provider],
Location: data.Location,
StorageType: data.StorageType,
}, error || Error(data.StorageType + ' Unmounted'));
Provider: data.Provider,
}, error || Error(data.Provider + ' Unmounted'));
};
helpers
.executeMount(data.Version, data.StorageType, data.Location, data.NoConsoleSupported, (error, pid) => {
.executeMount(data.Version, data.Provider, data.Location, data.NoConsoleSupported, (error, pid) => {
errorHandler(pid, error);
})
.then(() => {
standardIPCReply(event, Constants.IPC_Mount_Drive_Reply, {
StorageType: data.StorageType,
Provider: data.Provider,
});
})
.catch(error => {
@@ -843,7 +843,7 @@ ipcMain.on(Constants.IPC_Set_Config_Values, (event, data) => {
const setConfigValue = (i) => {
if (i < data.Items.length) {
helpers
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.StorageType, data.Version)
.setConfigValue(data.Items[i].Name, data.Items[i].Value, data.Provider, data.Version)
.then(() => {
setConfigValue(++i);
})
@@ -871,11 +871,11 @@ ipcMain.on(Constants.IPC_Show_Window + '_sync', event => {
});
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
clearManualMountDetection(data.StorageType);
clearManualMountDetection(data.Provider);
expectedUnmount[data.StorageType] = true;
expectedUnmount[data.Provider] = true;
helpers
.stopMountProcess(data.Version, data.StorageType)
.stopMountProcess(data.Version, data.Provider)
.then((result)=> {
console.log(result);
})