diff --git a/lib/local-fs.js b/lib/local-fs.js index 678494b11..43fd99d08 100644 --- a/lib/local-fs.js +++ b/lib/local-fs.js @@ -163,6 +163,7 @@ function lock_and_read(name, callback) { var buffer = new Buffer(st.size) fs.read(fd, buffer, 0, st.size, null, function(err, bytesRead, buffer) { + if (err) return callback(err) if (bytesRead != st.size) return callback(new Error('st.size != bytesRead'), fd) callback(null, fd, buffer) diff --git a/lib/local-storage.js b/lib/local-storage.js index a8621cafd..81e3460bb 100644 --- a/lib/local-storage.js +++ b/lib/local-storage.js @@ -90,7 +90,7 @@ Storage.prototype.remove_package = function(name, callback) { unlinkNext(function() { // try to unlink the directory, but ignore errors because it can fail self.storage(name).rmdir('.', function(err) { - callback() + callback(err) }) }) }) diff --git a/lib/up-storage.js b/lib/up-storage.js index d81a3384c..7ff19bd4c 100644 --- a/lib/up-storage.js +++ b/lib/up-storage.js @@ -158,7 +158,11 @@ Storage.prototype.request = function(options, cb) { } function do_decode() { - if (err) return error = err.message + if (err) { + error = err.message + return + } + if (options.json && res.statusCode < 300) { try { body = JSON.parse(body.toString('utf8')) @@ -204,7 +208,7 @@ Storage.prototype.request = function(options, cb) { self.status_check(true) } }) - req.on('error', function(err) { + req.on('error', function(_err) { if (!req._sinopia_aborted && !status_called) { status_called = true self.status_check(false)