assume cb is always supplied

This commit is contained in:
Michael Bradley, Jr 2018-09-11 15:44:37 -05:00
parent 803b3f5050
commit a4af0d8f5b
1 changed files with 2 additions and 2 deletions

View File

@ -161,7 +161,7 @@ function downloadFile(url, dest, cb) {
var file = o_fs.createWriteStream(dest); var file = o_fs.createWriteStream(dest);
(url.substring(0, 5) === 'https' ? https : http).get(url, function (response) { (url.substring(0, 5) === 'https' ? https : http).get(url, function (response) {
if (response.statusCode !== 200) { if (response.statusCode !== 200) {
if (cb) cb(`Download failed, response code ${response.statusCode}`); cb(`Download failed, response code ${response.statusCode}`);
return; return;
} }
response.pipe(file); response.pipe(file);
@ -170,7 +170,7 @@ function downloadFile(url, dest, cb) {
}); });
}).on('error', function (err) { }).on('error', function (err) {
o_fs.unlink(dest); o_fs.unlink(dest);
if (cb) cb(err.message); cb(err.message);
}); });
} }