[Continue S3 support] [Handle set configuration errors]
This commit is contained in:
@@ -424,7 +424,7 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
|
||||
try {
|
||||
const total = parseInt(response.headers['content-length'], 10);
|
||||
if (total === 0) {
|
||||
completeCallback(Error('No data available for download'));
|
||||
completeCallback(new Error('No data available for download'));
|
||||
} else {
|
||||
const stream = fs.createWriteStream(destination);
|
||||
|
||||
@@ -440,9 +440,9 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
|
||||
response.data.on('end', () => {
|
||||
stream.end(() => {
|
||||
if (downloaded === 0) {
|
||||
completeCallback(Error('Received 0 bytes'));
|
||||
completeCallback(new Error('Received 0 bytes'));
|
||||
} else if (downloaded !== total) {
|
||||
completeCallback(Error('Received incorrect number of bytes'));
|
||||
completeCallback(new Error('Received incorrect number of bytes'));
|
||||
} else {
|
||||
completeCallback();
|
||||
}
|
||||
@@ -731,7 +731,7 @@ module.exports.getDataDirectory = _getDataDirectory;
|
||||
module.exports.getMissingDependencies = dependencies => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!dependencies) {
|
||||
reject(Error('Dependency list is invalid'));
|
||||
reject(new Error('Dependency list is invalid'));
|
||||
}
|
||||
|
||||
let missing = [];
|
||||
@@ -782,7 +782,7 @@ module.exports.getMissingDependencies = dependencies => {
|
||||
hive = Registry.HKU;
|
||||
break;
|
||||
default:
|
||||
throw Error('Invalid registry hive: ' + hiveName);
|
||||
throw new Error('Invalid registry hive: ' + hiveName);
|
||||
}
|
||||
|
||||
const key = dep.registry[index].substr(hiveName.length);
|
||||
@@ -996,8 +996,12 @@ module.exports.setConfigValue = (name, value, provider, remote, s3, version) =>
|
||||
reject(err);
|
||||
});
|
||||
|
||||
process.on('exit', () => {
|
||||
resolve();
|
||||
process.on('exit', code => {
|
||||
if (code !== 0) {
|
||||
reject(new Error('Failed to set configuration value: ' + code));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
process.unref();
|
||||
@@ -1059,7 +1063,7 @@ module.exports.testRepertoryBinary = version => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(Error('Invalid exit code: ' + code));
|
||||
reject(new Error('Invalid exit code: ' + code));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -1080,7 +1084,7 @@ module.exports.verifyHash = (file, hash) => {
|
||||
command = 'sha256sum';
|
||||
args = ['-b', file, '-z'];
|
||||
} else {
|
||||
reject(Error('Platform not supported: ' + os.platform()))
|
||||
reject(new Error('Platform not supported: ' + os.platform()))
|
||||
}
|
||||
if (command) {
|
||||
execFile(command, args, (err, stdout) => {
|
||||
@@ -1091,7 +1095,7 @@ module.exports.verifyHash = (file, hash) => {
|
||||
if (hash2 === hash.toLowerCase()) {
|
||||
resolve(hash2);
|
||||
} else {
|
||||
reject(Error('Checksum failed for file'));
|
||||
reject(new Error('Checksum failed for file'));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1129,13 +1133,13 @@ module.exports.verifySignature = (file, signatureFile, publicKeyFile) => {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
reject(Error('Failed to locate \'openssl.exe\''));
|
||||
reject(new Error('Failed to locate \'openssl.exe\''));
|
||||
}
|
||||
});
|
||||
} else if (os.platform() === 'linux') {
|
||||
executeVerify('openssl');
|
||||
} else {
|
||||
reject(Error('Platform not supported: ' + os.platform()))
|
||||
reject(new Error('Platform not supported: ' + os.platform()))
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user