🗑 Remove more debugging output
This commit is contained in:
parent
52169d6160
commit
2548b00684
2 changed files with 8 additions and 13 deletions
|
@ -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,15 +22,13 @@ 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) => {
|
//TODO: need to throw error sync, not async
|
||||||
//TODO: need to throw error sync, not async
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue