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,

View File

@@ -123,7 +123,7 @@ module.exports.executeAsync = (command, args=[]) => {
const launchProcess = (count, timeout) => {
const processOptions = {
detached: true,
shell: true,
shell: false,
};
const process = new spawn(command, args, processOptions);
@@ -160,7 +160,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
return new Promise((resolve) => {
const processOptions = {
detached: false,
shell: true,
shell: os.platform() !== 'darwin',
stdio: 'ignore',
};
@@ -340,7 +340,7 @@ module.exports.getMissingDependencies = dependencies => {
} else {
for (const dep of dependencies) {
try {
if (!fs.lstatSync(dep.file).isFile()) {
if (!(fs.lstatSync(dep.file).isFile() || fs.lstatSync(dep.file).isSymbolicLink())) {
missing.push(dep);
}
} catch (e) {
@@ -442,8 +442,8 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
module.exports.stopMountProcess = (directory, version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: false,
shell: true,
detached: os.platform() === 'darwin',
shell: os.platform() !== 'darwin',
windowsHide: true,
};
@@ -464,13 +464,17 @@ module.exports.stopMountProcess = (directory, version, storageType) => {
Code: code,
});
});
if (os.platform() === 'darwin') {
process.unref();
}
});
};
module.exports.stopMountProcessSync = (directory, version, storageType) => {
const processOptions = {
detached: true,
shell: true,
shell: os.platform() !== 'darwin',
windowsHide: true,
};