🚑 Fix local file header reading for arraybuffer-based streams

This commit is contained in:
C-3PO 2018-07-05 23:02:08 +02:00
parent 0c8bc4d732
commit e84e5bd3d7
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -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<number> {
//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);