Skip to content

Commit

Permalink
defer end emit until a read happens
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Jun 17, 2023
1 parent 2fee69b commit 77070c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class Source extends Readable {
}

_read (cb) {
if (this.header.size === 0) {
this.push(null)
}
if (this._parent._stream === this) {
this._parent._update()
}
Expand Down Expand Up @@ -160,9 +163,7 @@ class Extract extends Writable {
this._applyLongHeaders()

if (this._header.size === 0 || this._header.type === 'directory') {
const stream = this._createStream()
stream.push(null)
this.emit('entry', this._header, stream, this._unlockBound)
this.emit('entry', this._header, this._createStream(), this._unlockBound)
return true
}

Expand Down

0 comments on commit 77070c6

Please sign in to comment.