Added unmount

This commit is contained in:
Scott E. Graves
2018-12-10 00:04:18 -06:00
parent af836c305c
commit 61b2f6e6f6
4 changed files with 24 additions and 44 deletions

View File

@@ -159,7 +159,7 @@ module.exports.executeAsync = (command, args=[]) => {
module.exports.executeMount = (directory, version, storageType, location, noConsoleSupported, exitCallback) => {
return new Promise((resolve) => {
const processOptions = {
detached: os.platform() === 'win32',
detached: false,
shell: true,
stdio: 'ignore',
};
@@ -199,9 +199,7 @@ module.exports.executeMount = (directory, version, storageType, location, noCons
exitCallback(code, pid);
});
if (os.platform() === 'win32') {
process.unref();
}
process.unref();
});
};
@@ -443,31 +441,22 @@ module.exports.setConfigValue = (name, value, directory, storageType, version) =
});
};
module.exports.stopMountProcess = (pid, location) => {
module.exports.stopMountProcess = (directory, version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
detached: false,
shell: true,
windowsHide: true,
};
let procName = 'kill';
if (location && location.length > 0) {
procName = 'fusermount';
}
const command = (os.platform() === 'win32') ? 'taskkill.exe' : procName;
const args = [];
if (os.platform() === 'win32') {
args.push('/PID');
}
if (procName === 'fusermount') {
args.push('-u');
args.push(location);
} else {
args.push(pid);
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
const args = ['-unmount'];
if (Constants.PROVIDER_ARG[storageType.toLowerCase()].length > 0) {
args.push(Constants.PROVIDER_ARG[storageType.toLowerCase()]);
}
const process = new spawn(command, args, processOptions);
const pid = process.pid;
process.on('error', (err) => {
reject(err);
});