From 77070c668b637a8ac2ea09925c7c940296a64d2a Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Sat, 17 Jun 2023 21:47:29 +0200 Subject: [PATCH] defer end emit until a read happens --- extract.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extract.js b/extract.js index acdb67d..0ed9f82 100644 --- a/extract.js +++ b/extract.js @@ -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() } @@ -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 }