Compare commits
No commits in common. "1e384904b9e4955282536166cc92633d37afffbe" and "2a1b1e9d999028f76abcaf860572589c7a815122" have entirely different histories.
1e384904b9
...
2a1b1e9d99
8 changed files with 20 additions and 63 deletions
20
constants.js
20
constants.js
|
@ -1,14 +1,12 @@
|
||||||
const constants = { // just for envs without fs
|
|
||||||
S_IFMT: 61440,
|
|
||||||
S_IFDIR: 16384,
|
|
||||||
S_IFCHR: 8192,
|
|
||||||
S_IFBLK: 24576,
|
|
||||||
S_IFIFO: 4096,
|
|
||||||
S_IFLNK: 40960
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
module.exports = require('fs').constants || constants
|
module.exports = require('fs').constants
|
||||||
} catch {
|
} catch {
|
||||||
module.exports = constants
|
module.exports = { // just for envs without fs
|
||||||
|
S_IFMT: 61440,
|
||||||
|
S_IFDIR: 16384,
|
||||||
|
S_IFCHR: 8192,
|
||||||
|
S_IFBLK: 24576,
|
||||||
|
S_IFIFO: 4096,
|
||||||
|
S_IFLNK: 40960
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,6 @@ class Source extends Readable {
|
||||||
}
|
}
|
||||||
|
|
||||||
_read (cb) {
|
_read (cb) {
|
||||||
if (this.header.size === 0) {
|
|
||||||
this.push(null)
|
|
||||||
}
|
|
||||||
if (this._parent._stream === this) {
|
if (this._parent._stream === this) {
|
||||||
this._parent._update()
|
this._parent._update()
|
||||||
}
|
}
|
||||||
|
@ -163,7 +160,9 @@ class Extract extends Writable {
|
||||||
this._applyLongHeaders()
|
this._applyLongHeaders()
|
||||||
|
|
||||||
if (this._header.size === 0 || this._header.type === 'directory') {
|
if (this._header.size === 0 || this._header.type === 'directory') {
|
||||||
this.emit('entry', this._header, this._createStream(), this._unlockBound)
|
const stream = this._createStream()
|
||||||
|
stream.push(null)
|
||||||
|
this.emit('entry', this._header, stream, this._unlockBound)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
pack.js
20
pack.js
|
@ -11,7 +11,7 @@ const END_OF_TAR = b4a.alloc(1024)
|
||||||
|
|
||||||
class Sink extends Writable {
|
class Sink extends Writable {
|
||||||
constructor (pack, header, callback) {
|
constructor (pack, header, callback) {
|
||||||
super({ mapWritable, eagerOpen: true })
|
super({ mapWritable })
|
||||||
|
|
||||||
this.written = 0
|
this.written = 0
|
||||||
this.header = header
|
this.header = header
|
||||||
|
@ -49,10 +49,6 @@ class Sink extends Writable {
|
||||||
this._pack._encode(this.header)
|
this._pack._encode(this.header)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._isVoid) {
|
|
||||||
this._finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
cb(null)
|
cb(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,10 +67,7 @@ class Sink extends Writable {
|
||||||
this._pack._drain = cb
|
this._pack._drain = cb
|
||||||
}
|
}
|
||||||
|
|
||||||
_finish () {
|
_final (cb) {
|
||||||
if (this._finished) return
|
|
||||||
this._finished = true
|
|
||||||
|
|
||||||
if (this._isLinkname) {
|
if (this._isLinkname) {
|
||||||
this.header.linkname = this._linkname ? b4a.toString(this._linkname, 'utf-8') : ''
|
this.header.linkname = this._linkname ? b4a.toString(this._linkname, 'utf-8') : ''
|
||||||
this._pack._encode(this.header)
|
this._pack._encode(this.header)
|
||||||
|
@ -82,15 +75,13 @@ class Sink extends Writable {
|
||||||
|
|
||||||
overflow(this._pack, this.header.size)
|
overflow(this._pack, this.header.size)
|
||||||
|
|
||||||
this._pack._done(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
_final (cb) {
|
|
||||||
if (this.written !== this.header.size) { // corrupting tar
|
if (this.written !== this.header.size) { // corrupting tar
|
||||||
return cb(new Error('Size mismatch'))
|
return cb(new Error('Size mismatch'))
|
||||||
}
|
}
|
||||||
|
|
||||||
this._finish()
|
this._pack._done(this)
|
||||||
|
this._finished = true
|
||||||
|
|
||||||
cb(null)
|
cb(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +142,7 @@ class Pack extends Readable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sink._isVoid) {
|
if (sink._isVoid) {
|
||||||
|
sink.end()
|
||||||
return sink
|
return sink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "tar-stream",
|
"name": "tar-stream",
|
||||||
"version": "3.1.4",
|
"version": "3.1.0",
|
||||||
"description": "tar-stream is a streaming tar parser and generator and nothing else. It operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.",
|
"description": "tar-stream is a streaming tar parser and generator and nothing else. It operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -24,7 +24,6 @@
|
||||||
"homepage": "https://github.com/mafintosh/tar-stream",
|
"homepage": "https://github.com/mafintosh/tar-stream",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"b4a": "^1.6.4",
|
"b4a": "^1.6.4",
|
||||||
"fast-fifo": "^1.2.0",
|
|
||||||
"streamx": "^2.15.0"
|
"streamx": "^2.15.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -251,7 +251,7 @@ test('pax', function (t) {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('types', function (t) {
|
test('types', function (t) {
|
||||||
t.plan(5)
|
t.plan(3)
|
||||||
|
|
||||||
const extract = tar.extract()
|
const extract = tar.extract()
|
||||||
let noEntries = false
|
let noEntries = false
|
||||||
|
@ -283,9 +283,6 @@ test('types', function (t) {
|
||||||
stream.on('data', function () {
|
stream.on('data', function () {
|
||||||
t.ok(false)
|
t.ok(false)
|
||||||
})
|
})
|
||||||
stream.on('end', function () {
|
|
||||||
t.pass('ended')
|
|
||||||
})
|
|
||||||
extract.once('entry', onlink)
|
extract.once('entry', onlink)
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
@ -309,9 +306,6 @@ test('types', function (t) {
|
||||||
stream.on('data', function () {
|
stream.on('data', function () {
|
||||||
t.ok(false)
|
t.ok(false)
|
||||||
})
|
})
|
||||||
stream.on('end', function () {
|
|
||||||
t.pass('ended')
|
|
||||||
})
|
|
||||||
noEntries = true
|
noEntries = true
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
@ -676,26 +670,6 @@ test('gnu-incremental', function (t) {
|
||||||
extract.end(fs.readFileSync(fixtures.GNU_INCREMENTAL_TAR))
|
extract.end(fs.readFileSync(fixtures.GNU_INCREMENTAL_TAR))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('i-dont-know', function (t) {
|
|
||||||
t.plan(1)
|
|
||||||
const extract = tar.extract()
|
|
||||||
|
|
||||||
extract.on('entry', function (header, stream, cb) {
|
|
||||||
console.debug(header.name)
|
|
||||||
stream.on('end', function () {
|
|
||||||
cb() // ready for next entry
|
|
||||||
})
|
|
||||||
|
|
||||||
stream.resume()
|
|
||||||
})
|
|
||||||
|
|
||||||
extract.on('finish', function () {
|
|
||||||
t.ok(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
extract.end(fs.readFileSync(fixtures.I_DONT_KNOW))
|
|
||||||
})
|
|
||||||
|
|
||||||
test('v7 unsupported', function (t) { // correctly fails to parse v7 tarballs
|
test('v7 unsupported', function (t) { // correctly fails to parse v7 tarballs
|
||||||
t.plan(1)
|
t.plan(1)
|
||||||
|
|
||||||
|
|
1
test/fixtures/.gitattributes
vendored
1
test/fixtures/.gitattributes
vendored
|
@ -1 +0,0 @@
|
||||||
i-dont-know.tgz filter=lfs diff=lfs merge=lfs -text
|
|
BIN
test/fixtures/i-dont-know.tgz
(Stored with Git LFS)
vendored
BIN
test/fixtures/i-dont-know.tgz
(Stored with Git LFS)
vendored
Binary file not shown.
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
|
@ -25,4 +25,3 @@ exports.GNU_INCREMENTAL_TAR = path.join(__dirname, 'gnu-incremental.tar')
|
||||||
exports.UNKNOWN_FORMAT = path.join(__dirname, 'unknown-format.tar')
|
exports.UNKNOWN_FORMAT = path.join(__dirname, 'unknown-format.tar')
|
||||||
// Created using gnu tar: tar cf v7.tar --format v7 test.txt
|
// Created using gnu tar: tar cf v7.tar --format v7 test.txt
|
||||||
exports.V7_TAR = path.join(__dirname, 'v7.tar')
|
exports.V7_TAR = path.join(__dirname, 'v7.tar')
|
||||||
exports.I_DONT_KNOW = path.join(__dirname, 'i-dont-know.tgz')
|
|
||||||
|
|
Loading…
Reference in a new issue