OS X changes
This commit is contained in:
45
electron.js
45
electron.js
@@ -279,11 +279,13 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
const grabDriveLetters = (locations) => {
|
const grabDriveLetters = (locations) => {
|
||||||
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
|
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
|
||||||
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
||||||
let driveInUse = false;
|
let driveInUse;
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
if (locations.length > 0) {
|
||||||
driveInUse = locations[provider].startsWith(drive);
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
if (driveInUse)
|
driveInUse = locations[provider].startsWith(drive);
|
||||||
break;
|
if (driveInUse)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!driveInUse) {
|
if (!driveInUse) {
|
||||||
try {
|
try {
|
||||||
@@ -297,12 +299,14 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
if (locations.length > 0) {
|
||||||
if (locations[provider].length > 0) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
if (!driveLetters[provider].find((driveLetter) => {
|
if (locations[provider].length > 0) {
|
||||||
return driveLetter === locations[provider];
|
if (!driveLetters[provider].find((driveLetter) => {
|
||||||
})) {
|
return driveLetter === locations[provider];
|
||||||
driveLetters[provider].push(locations[provider]);
|
})) {
|
||||||
|
driveLetters[provider].push(locations[provider]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,10 +315,12 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
const setImage = (locations) => {
|
const setImage = (locations) => {
|
||||||
if (os.platform() === 'win32' || os.platform() === 'linux') {
|
if (os.platform() === 'win32' || os.platform() === 'linux') {
|
||||||
let driveInUse;
|
let driveInUse;
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
if (locations.length > 0) {
|
||||||
driveInUse = locations[provider].length > 0;
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
if (driveInUse)
|
driveInUse = locations[provider].length > 0;
|
||||||
break;
|
if (driveInUse)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let image;
|
let image;
|
||||||
@@ -357,8 +363,11 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
grabDriveLetters('', '');
|
console.log(error);
|
||||||
setImage('', '');
|
if (os.platform() === 'win32') {
|
||||||
|
grabDriveLetters({});
|
||||||
|
}
|
||||||
|
setImage({});
|
||||||
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
||||||
DriveLetters: driveLetters,
|
DriveLetters: driveLetters,
|
||||||
}, error);
|
}, error);
|
||||||
@@ -470,6 +479,7 @@ ipcMain.on(Constants.IPC_Grab_UI_Releases, (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
|
ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
|
||||||
|
console.log(data);
|
||||||
if (data.Source.toLowerCase().endsWith('.dmg')) {
|
if (data.Source.toLowerCase().endsWith('.dmg')) {
|
||||||
helpers
|
helpers
|
||||||
.executeAsync('hdiutil', ['attach', data.Source])
|
.executeAsync('hdiutil', ['attach', data.Source])
|
||||||
@@ -480,6 +490,7 @@ ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error=> {
|
.catch(error=> {
|
||||||
|
console.log(error);
|
||||||
standardIPCReply(event, Constants.IPC_Install_Dependency_Reply, {
|
standardIPCReply(event, Constants.IPC_Install_Dependency_Reply, {
|
||||||
Source: data.Source,
|
Source: data.Source,
|
||||||
URL: data.URL,
|
URL: data.URL,
|
||||||
|
|||||||
16
helpers.js
16
helpers.js
@@ -123,7 +123,7 @@ module.exports.executeAsync = (command, args=[]) => {
|
|||||||
const launchProcess = (count, timeout) => {
|
const launchProcess = (count, timeout) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
shell: true,
|
shell: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const process = new spawn(command, args, processOptions);
|
const process = new spawn(command, args, processOptions);
|
||||||
@@ -160,7 +160,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: false,
|
detached: false,
|
||||||
shell: true,
|
shell: os.platform() !== 'darwin',
|
||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ module.exports.getMissingDependencies = dependencies => {
|
|||||||
} else {
|
} else {
|
||||||
for (const dep of dependencies) {
|
for (const dep of dependencies) {
|
||||||
try {
|
try {
|
||||||
if (!fs.lstatSync(dep.file).isFile()) {
|
if (!(fs.lstatSync(dep.file).isFile() || fs.lstatSync(dep.file).isSymbolicLink())) {
|
||||||
missing.push(dep);
|
missing.push(dep);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -442,8 +442,8 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
|
|||||||
module.exports.stopMountProcess = (directory, version, storageType) => {
|
module.exports.stopMountProcess = (directory, version, storageType) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: false,
|
detached: os.platform() === 'darwin',
|
||||||
shell: true,
|
shell: os.platform() !== 'darwin',
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -464,13 +464,17 @@ module.exports.stopMountProcess = (directory, version, storageType) => {
|
|||||||
Code: code,
|
Code: code,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
process.unref();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.stopMountProcessSync = (directory, version, storageType) => {
|
module.exports.stopMountProcessSync = (directory, version, storageType) => {
|
||||||
const processOptions = {
|
const processOptions = {
|
||||||
detached: true,
|
detached: true,
|
||||||
shell: true,
|
shell: os.platform() !== 'darwin',
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user