OS X changes

This commit is contained in:
Scott E. Graves
2018-12-11 20:52:59 -06:00
parent daa46fd9d7
commit 0e5dc5d16a
2 changed files with 38 additions and 23 deletions

View File

@@ -279,11 +279,13 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
const grabDriveLetters = (locations) => {
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
const drive = (String.fromCharCode(i) + ':').toUpperCase();
let driveInUse = false;
for (const provider of Constants.PROVIDER_LIST) {
driveInUse = locations[provider].startsWith(drive);
if (driveInUse)
break;
let driveInUse;
if (locations.length > 0) {
for (const provider of Constants.PROVIDER_LIST) {
driveInUse = locations[provider].startsWith(drive);
if (driveInUse)
break;
}
}
if (!driveInUse) {
try {
@@ -297,12 +299,14 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
}
}
for (const provider of Constants.PROVIDER_LIST) {
if (locations[provider].length > 0) {
if (!driveLetters[provider].find((driveLetter) => {
return driveLetter === locations[provider];
})) {
driveLetters[provider].push(locations[provider]);
if (locations.length > 0) {
for (const provider of Constants.PROVIDER_LIST) {
if (locations[provider].length > 0) {
if (!driveLetters[provider].find((driveLetter) => {
return driveLetter === locations[provider];
})) {
driveLetters[provider].push(locations[provider]);
}
}
}
}
@@ -311,10 +315,12 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
const setImage = (locations) => {
if (os.platform() === 'win32' || os.platform() === 'linux') {
let driveInUse;
for (const provider of Constants.PROVIDER_LIST) {
driveInUse = locations[provider].length > 0;
if (driveInUse)
break;
if (locations.length > 0) {
for (const provider of Constants.PROVIDER_LIST) {
driveInUse = locations[provider].length > 0;
if (driveInUse)
break;
}
}
let image;
@@ -357,8 +363,11 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
});
})
.catch(error => {
grabDriveLetters('', '');
setImage('', '');
console.log(error);
if (os.platform() === 'win32') {
grabDriveLetters({});
}
setImage({});
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
DriveLetters: driveLetters,
}, error);
@@ -470,6 +479,7 @@ ipcMain.on(Constants.IPC_Grab_UI_Releases, (event) => {
});
ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
console.log(data);
if (data.Source.toLowerCase().endsWith('.dmg')) {
helpers
.executeAsync('hdiutil', ['attach', data.Source])
@@ -480,6 +490,7 @@ ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
});
})
.catch(error=> {
console.log(error);
standardIPCReply(event, Constants.IPC_Install_Dependency_Reply, {
Source: data.Source,
URL: data.URL,