fix(core): update
This commit is contained in:
@ -49,13 +49,17 @@ export function unbzip2Stream() {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
broken = true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
let counter = 0;
|
||||
return new plugins.smartstream.SmartDuplex({
|
||||
objectMode: true,
|
||||
// writableObjectMode: true,
|
||||
name: 'bzip2',
|
||||
debug: true,
|
||||
highWaterMark: 1,
|
||||
writeFunction: async function (data, streamTools) {
|
||||
//console.error('received', data.length,'bytes in', typeof data);
|
||||
console.log(`got chunk ${counter++}`)
|
||||
bufferQueue.push(data);
|
||||
hasBytes += data.length;
|
||||
if (bitReader === null) {
|
||||
@ -66,6 +70,10 @@ export function unbzip2Stream() {
|
||||
while (!broken && hasBytes - bitReader.bytesRead + 1 >= (25000 + 100000 * blockSize || 4)) {
|
||||
//console.error('decompressing with', hasBytes - bitReader.bytesRead + 1, 'bytes in buffer');
|
||||
const result = await decompressAndPush();
|
||||
if (!result) {
|
||||
continue;
|
||||
}
|
||||
// console.log(result.toString());
|
||||
await streamTools.push(result);
|
||||
}
|
||||
},
|
||||
@ -73,11 +81,10 @@ export function unbzip2Stream() {
|
||||
//console.error(x,'last compressing with', hasBytes, 'bytes in buffer');
|
||||
while (!broken && bitReader && hasBytes > bitReader.bytesRead) {
|
||||
const result = await decompressAndPush();
|
||||
streamTools.push(result);
|
||||
await streamTools.push(result);
|
||||
}
|
||||
if (!broken) {
|
||||
if (streamCRC !== null) this.emit('error', new Error('input stream ended prematurely'));
|
||||
this.queue(null);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user