aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tar-stream/extract.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/tar-stream/extract.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/tar-stream/extract.js')
-rw-r--r--node_modules/tar-stream/extract.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/node_modules/tar-stream/extract.js b/node_modules/tar-stream/extract.js
index 8be2a472c..19a4255a3 100644
--- a/node_modules/tar-stream/extract.js
+++ b/node_modules/tar-stream/extract.js
@@ -22,6 +22,7 @@ var emptyStream = function (self, offset) {
var mixinPax = function (header, pax) {
if (pax.path) header.name = pax.path
if (pax.linkpath) header.linkname = pax.linkpath
+ if (pax.size) header.size = parseInt(pax.size, 10)
header.pax = pax
return header
}
@@ -42,9 +43,12 @@ var Extract = function (opts) {
if (!(this instanceof Extract)) return new Extract(opts)
Writable.call(this, opts)
+ opts = opts || {}
+
this._offset = 0
this._buffer = bl()
this._missing = 0
+ this._partial = false
this._onparse = noop
this._header = null
this._stream = null
@@ -101,14 +105,14 @@ var Extract = function (opts) {
var ongnulongpath = function () {
var size = self._header.size
- this._gnuLongPath = headers.decodeLongPath(b.slice(0, size))
+ this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)
b.consume(size)
onstreamend()
}
var ongnulonglinkpath = function () {
var size = self._header.size
- this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size))
+ this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)
b.consume(size)
onstreamend()
}
@@ -117,7 +121,7 @@ var Extract = function (opts) {
var offset = self._offset
var header
try {
- header = self._header = headers.decode(b.slice(0, 512))
+ header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding)
} catch (err) {
self.emit('error', err)
}
@@ -179,6 +183,7 @@ var Extract = function (opts) {
oncontinue()
}
+ this._onheader = onheader
this._parse(512, onheader)
}
@@ -197,6 +202,7 @@ Extract.prototype._parse = function (size, onparse) {
if (this._destroyed) return
this._offset += size
this._missing = size
+ if (onparse === this._onheader) this._partial = false
this._onparse = onparse
}
@@ -214,6 +220,7 @@ Extract.prototype._write = function (data, enc, cb) {
var s = this._stream
var b = this._buffer
var missing = this._missing
+ if (data.length) this._partial = true
// we do not reach end-of-chunk now. just forward it
@@ -243,4 +250,9 @@ Extract.prototype._write = function (data, enc, cb) {
this._onparse()
}
+Extract.prototype._final = function (cb) {
+ if (this._partial) return this.destroy(new Error('Unexpected end of data'))
+ cb()
+}
+
module.exports = Extract