diff --git a/extract.js b/extract.js index aa0830f..19a4255 100644 --- a/extract.js +++ b/extract.js @@ -182,8 +182,8 @@ var Extract = function (opts) { self._parse(header.size, onstreamend) oncontinue() } - this._onheader = onheader + this._onheader = onheader this._parse(512, onheader) } @@ -251,7 +251,7 @@ Extract.prototype._write = function (data, enc, cb) { } Extract.prototype._final = function (cb) { - if (this._partial) cb(new Error('unexpected end of data')) + if (this._partial) return this.destroy(new Error('Unexpected end of data')) cb() } diff --git a/test/extract.js b/test/extract.js index 343a45a..a244c0b 100644 --- a/test/extract.js +++ b/test/extract.js @@ -572,7 +572,7 @@ test('latin-1', function (t) { // can unpack filenames encoded in latin-1 }) test('incomplete', function (t) { - t.plan(2) + t.plan(1) var extract = tar.extract() @@ -581,11 +581,11 @@ test('incomplete', function (t) { }) extract.on('error', function (err) { - t.same(err.message, 'unexpected end of data') + t.same(err.message, 'Unexpected end of data') }) extract.on('finish', function () { - t.ok(true) + t.fail('should not finish') }) extract.end(fs.readFileSync(fixtures.INCOMPLETE_TAR))