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);