From e84e5bd3d7f7854d16a1811e215fdaae07237703 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 23:02:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Fix=20local=20file=20header=20re?= =?UTF-8?q?ading=20for=20arraybuffer-based=20streams?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/streams/readLocalFileHeader.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ssn/streams/readLocalFileHeader.ts b/src/ssn/streams/readLocalFileHeader.ts index adc8eb5..84230eb 100644 --- a/src/ssn/streams/readLocalFileHeader.ts +++ b/src/ssn/streams/readLocalFileHeader.ts @@ -17,9 +17,12 @@ function waitReadableLength(inputStream: stream.Readable, minLength: number): Pr * Returns length of the local file header. */ export default async function readLocalFileHeader(inputStream: stream.Readable): Promise { - //TODO: need to wait until - await waitReadableLength(inputStream, 30); - const localFileHeader: Buffer = inputStream.read(30); + let localFileHeader: Buffer = inputStream.read(30); + if (localFileHeader === null) { + //need to wait until data is ready for reading + await waitReadableLength(inputStream, 30); + localFileHeader = inputStream.read(30); + } //Local file header signature const magic = localFileHeader.readUInt32LE(0);