fix(core): update

This commit is contained in:
2023-11-13 22:11:24 +01:00
parent 21da75c09a
commit f87359fb97
5 changed files with 22 additions and 16 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartarchive',
version: '4.0.14',
version: '4.0.15',
description: 'work with archives'
}

View File

@ -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);
}
},
});

View File

@ -42,13 +42,13 @@ export class ArchiveAnalyzer {
return this.smartArchiveRef.tarTools.getDecompressionStream(); // replace with your own tar decompression stream
default:
// Handle unsupported formats or no decompression needed
return new plugins.smartstream.PassThrough();
return plugins.smartstream.createPassThrough();
}
}
public getAnalyzedStream() {
let firstRun = true;
const resultStream = new plugins.smartstream.PassThrough();
const resultStream = plugins.smartstream.createPassThrough();
const analyzerstream = new plugins.smartstream.SmartDuplex<Buffer, IAnalyzedResult>({
readableObjectMode: true,
writeFunction: async (chunkArg: Buffer, streamtools) => {
@ -63,8 +63,7 @@ export class ArchiveAnalyzer {
resultStream,
decompressionStream,
};
streamtools.push(result);
streamtools.push(null);
await streamtools.push(result);
return null;
}
},