Allow to stream symlink location if 'linkname' header field is not defined

This commit is contained in:
Jesús Leganés Combarro "piranna 2015-10-11 19:28:28 +02:00
parent b2f57d1b24
commit b32e9b6b39

29
pack.js
View file

@ -112,15 +112,40 @@ Pack.prototype.entry = function(header, buffer, callback) {
process.nextTick(callback) process.nextTick(callback)
return new Void() return new Void()
} }
if (header.type === 'symlink' && !header.linkname) {
var stream = new Writable
var linkname = ''
stream._write = function(data, enc, cb)
{
linkname += data
cb()
}
eos(stream, function(err)
{
if (err) { // stream was closed
self.destroy()
return callback(err)
}
header.linkname = linkname
self._encode(header)
callback()
})
return stream
}
this._encode(header)
if (header.type !== 'file' && header.type !== 'contigious-file') { if (header.type !== 'file' && header.type !== 'contigious-file') {
this._encode(header)
process.nextTick(callback) process.nextTick(callback)
return new Void() return new Void()
} }
var sink = new Sink(this) var sink = new Sink(this)
this._encode(header)
this._stream = sink this._stream = sink
eos(sink, function(err) { eos(sink, function(err) {