diff --git a/lib/install.js b/lib/install.js index 5bd11a9e..e8549186 100644 --- a/lib/install.js +++ b/lib/install.js @@ -92,6 +92,7 @@ function place_binary(from,to,opts,callback) { if (!req) return callback(new Error("empty req")); var badDownload = false; var extractCount = 0; + var hasResponse = false; var tar = require('tar'); function afterTarball(err) { @@ -122,7 +123,7 @@ function place_binary(from,to,opts,callback) { }); req.on('close', function () { - if (extractCount === 0) { + if (!hasResponse) { return callback(new Error('Connection closed while downloading tarball file')); } }); @@ -132,6 +133,7 @@ function place_binary(from,to,opts,callback) { if (http_get.type === 'needle' && res.headers.hasOwnProperty('location') && res.headers.location !== '') { return; } + hasResponse = true; if (res.statusCode !== 200) { badDownload = true; var err = new Error(res.statusCode + ' status code downloading tarball ' + from);