Refactoring

This commit is contained in:
Scott E. Graves
2019-01-29 17:13:59 -06:00
parent a8f1724166
commit d16d417c99
5 changed files with 209 additions and 189 deletions

View File

@@ -259,7 +259,7 @@ const standardIPCReply = (event, channel, data, error) => {
}
};
ipcMain.on(Constants.IPC_Browse_Directory, (event, data) => {
ipcMain.on(Constants.IPC_Browse_Directory + '_sync', (event, data) => {
dialog.showOpenDialog(mainWindow, {
defaultPath: data.Location,
properties: ['openDirectory'],
@@ -286,6 +286,23 @@ ipcMain.on(Constants.IPC_Check_Dependency_Installed, (event, data) => {
}
});
ipcMain.on(Constants.IPC_Check_Dependency_Installed + '_sync', (event, data) => {
try {
const exists = fs.lstatSync(data.File).isFile();
event.returnValue = {
data: {
Exists: exists
},
};
} catch (e) {
event.returnValue = {
data: {
Exists: false
},
};
}
});
ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
const dataDirectory = helpers.resolvePath(data.Directory);
const destination = path.join(dataDirectory, data.Version);
@@ -310,7 +327,7 @@ ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
});
});
ipcMain.on(Constants.IPC_Check_Mount_Location, (event, data) => {
ipcMain.on(Constants.IPC_Check_Mount_Location + '_sync', (event, data) => {
let response = {
Success: true,
Error: ''
@@ -342,6 +359,21 @@ ipcMain.on(Constants.IPC_Delete_File, (event, data) => {
}
});
ipcMain.on(Constants.IPC_Delete_File + '_sync', (event, data) => {
try {
if (fs.existsSync(data.FilePath)) {
fs.unlinkSync(data.FilePath);
}
event.returnValue = {
data: true,
};
} catch (e) {
event.returnValue = {
data: false,
};
}
});
ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
let driveLetters = {};
for (const provider of Constants.PROVIDER_LIST) {