🗑 Remove more debugging output

This commit is contained in:
C-3PO 2018-07-08 23:32:22 +02:00
parent 52169d6160
commit 2548b00684
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 8 additions and 13 deletions

View file

@ -11,7 +11,7 @@ import readBytesFromStream from './streams/readBytesFromStream';
* The stream must already start at the .zip's local file header * The stream must already start at the .zip's local file header
* and must transparently span across multiple disks if necessary. * and must transparently span across multiple disks if necessary.
*/ */
export default async function extractFileAsStream(file: ISsnFileEntry, inputStream: stream.Readable, skipDecompression: boolean = false): Promise<stream.Readable> { export default async function extractFileAsStream(file: ISsnFileEntry, inputStream: stream.Readable): Promise<stream.Readable> {
let curStream = inputStream; let curStream = inputStream;
//pipe into decryption if file is encrypted //pipe into decryption if file is encrypted
@ -22,7 +22,6 @@ export default async function extractFileAsStream(file: ISsnFileEntry, inputStre
await readBytesFromStream(curStream, 12); await readBytesFromStream(curStream, 12);
} }
if (!skipDecompression) {
//pipe into decompression //pipe into decompression
const decompressTransform = zlib.createInflateRaw(); const decompressTransform = zlib.createInflateRaw();
decompressTransform.on('error', (error) => { decompressTransform.on('error', (error) => {
@ -30,7 +29,6 @@ export default async function extractFileAsStream(file: ISsnFileEntry, inputStre
throw new Error(`Error during decompression of "${file.name}": ${error.message}`); throw new Error(`Error during decompression of "${file.name}": ${error.message}`);
}); });
curStream = curStream.pipe(decompressTransform); curStream = curStream.pipe(decompressTransform);
}
return curStream; return curStream;
} }

View file

@ -4,7 +4,6 @@ import * as stream from 'stream';
function waitReadableLength(inputStream: stream.Readable, minLength: number): Promise<void> { function waitReadableLength(inputStream: stream.Readable, minLength: number): Promise<void> {
return new Promise((resolve) => { return new Promise((resolve) => {
const interval = setInterval(() => { const interval = setInterval(() => {
console.log('waiting...', inputStream.readableLength, minLength);
if (inputStream.readableLength >= minLength) { if (inputStream.readableLength >= minLength) {
clearInterval(interval); clearInterval(interval);
resolve(); 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. */ /** 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<Buffer> { export default async function readBytesFromStream(inputStream: stream.Readable, length: number): Promise<Buffer> {
let localFileHeader: Buffer = inputStream.read(length); let localFileHeader: Buffer = inputStream.read(length);
console.log(localFileHeader);
while (localFileHeader === null) { while (localFileHeader === null) {
//need to wait until data is ready for reading //need to wait until data is ready for reading
await waitReadableLength(inputStream, length); await waitReadableLength(inputStream, length);
localFileHeader = inputStream.read(length); localFileHeader = inputStream.read(length);
console.log(localFileHeader);
} }
return localFileHeader; return localFileHeader;
} }