From 2548b00684520416e9725b992c655be02f50e733 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Sun, 8 Jul 2018 23:32:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=20Remove=20more=20debugging=20outp?= =?UTF-8?q?ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/extractFileAsStream.ts | 18 ++++++++---------- src/ssn/streams/readBytesFromStream.ts | 3 --- 2 files changed, 8 insertions(+), 13 deletions(-) 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; }