diff --git a/src/ssn/extractFileAsStream.ts b/src/ssn/extractFileAsStream.ts index 6bab925..4e45a08 100644 --- a/src/ssn/extractFileAsStream.ts +++ b/src/ssn/extractFileAsStream.ts @@ -11,7 +11,7 @@ import readBytesFromStream from './streams/readBytesFromStream'; * The stream must already start at the .zip's local file header * and must transparently span across multiple disks if necessary. */ -export default async function extractFileAsStream(file: ISsnFileEntry, inputStream: stream.Readable, skipDecompression: boolean = false): Promise { +export default async function extractFileAsStream(file: ISsnFileEntry, inputStream: stream.Readable): Promise { let curStream = inputStream; //pipe into decryption if file is encrypted @@ -22,15 +22,13 @@ export default async function extractFileAsStream(file: ISsnFileEntry, inputStre await readBytesFromStream(curStream, 12); } - if (!skipDecompression) { - //pipe into decompression - const decompressTransform = zlib.createInflateRaw(); - decompressTransform.on('error', (error) => { - //TODO: need to throw error sync, not async - throw new Error(`Error during decompression of "${file.name}": ${error.message}`); - }); - curStream = curStream.pipe(decompressTransform); - } + //pipe into decompression + const decompressTransform = zlib.createInflateRaw(); + decompressTransform.on('error', (error) => { + //TODO: need to throw error sync, not async + throw new Error(`Error during decompression of "${file.name}": ${error.message}`); + }); + curStream = curStream.pipe(decompressTransform); return curStream; } diff --git a/src/ssn/streams/readBytesFromStream.ts b/src/ssn/streams/readBytesFromStream.ts index f93adf1..6f5a490 100644 --- a/src/ssn/streams/readBytesFromStream.ts +++ b/src/ssn/streams/readBytesFromStream.ts @@ -4,7 +4,6 @@ import * as stream from 'stream'; function waitReadableLength(inputStream: stream.Readable, minLength: number): Promise { return new Promise((resolve) => { const interval = setInterval(() => { - console.log('waiting...', inputStream.readableLength, minLength); if (inputStream.readableLength >= minLength) { clearInterval(interval); resolve(); @@ -16,12 +15,10 @@ function waitReadableLength(inputStream: stream.Readable, minLength: number): Pr /** Reads the given number of bytes from the stream and returns them as a buffer, optionally waiting until the bytes are ready for reading. */ export default async function readBytesFromStream(inputStream: stream.Readable, length: number): Promise { let localFileHeader: Buffer = inputStream.read(length); - console.log(localFileHeader); while (localFileHeader === null) { //need to wait until data is ready for reading await waitReadableLength(inputStream, length); localFileHeader = inputStream.read(length); - console.log(localFileHeader); } return localFileHeader; }