Clean up a couple DEP0013 spots

This commit is contained in:
Bryan Ashby 2018-06-25 19:09:08 -06:00
parent c99074ba27
commit 2fa9d6a3c2
1 changed files with 21 additions and 5 deletions

View File

@ -280,12 +280,20 @@ function attemptSetEstimatedReleaseDate(fileEntry) {
} }
// a simple log proxy for when we call from oputil.js // a simple log proxy for when we call from oputil.js
function logDebug(obj, msg) { const logDebug = (obj, msg) => {
if(Log) { if(Log) {
Log.debug(obj, msg); Log.debug(obj, msg);
} }
} }
const logError = (obj, msg) => {
if(Log) {
Log.error(obj, msg);
} else {
console.error(`${msg}: ${JSON.stringify(obj)}`);
}
}
function extractAndProcessDescFiles(fileEntry, filePath, archiveEntries, cb) { function extractAndProcessDescFiles(fileEntry, filePath, archiveEntries, cb) {
async.waterfall( async.waterfall(
[ [
@ -709,8 +717,12 @@ function scanFile(filePath, options, iterator, cb) {
const nextChunk = () => { const nextChunk = () => {
fs.read(fd, buffer, 0, chunkSize, null, (err, bytesRead) => { fs.read(fd, buffer, 0, chunkSize, null, (err, bytesRead) => {
if(err) { if(err) {
fs.close(fd); return fs.close(fd, closeErr => {
if(closeErr) {
logError( { filePath, error : err.message }, 'Failed to close file');
}
return readErrorCallIter(err, callback); return readErrorCallIter(err, callback);
});
} }
if(0 === bytesRead) { if(0 === bytesRead) {
@ -729,8 +741,12 @@ function scanFile(filePath, options, iterator, cb) {
} }
stepInfo.step = 'hash_finish'; stepInfo.step = 'hash_finish';
fs.close(fd); return fs.close(fd, closeErr => {
if(closeErr) {
logError( { filePath, error : err.message }, 'Failed to close file');
}
return callIter(callback); return callIter(callback);
});
} }
stepInfo.bytesProcessed += bytesRead; stepInfo.bytesProcessed += bytesRead;