fix(core): update

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

View File

@ -26,7 +26,7 @@
"@push.rocks/smartpromise": "^4.0.3", "@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrequest": "^2.0.21", "@push.rocks/smartrequest": "^2.0.21",
"@push.rocks/smartrx": "^3.0.7", "@push.rocks/smartrx": "^3.0.7",
"@push.rocks/smartstream": "^3.0.26", "@push.rocks/smartstream": "^3.0.27",
"@push.rocks/smartunique": "^3.0.6", "@push.rocks/smartunique": "^3.0.6",
"@push.rocks/smarturl": "^3.0.7", "@push.rocks/smarturl": "^3.0.7",
"@types/tar-stream": "^3.1.3", "@types/tar-stream": "^3.1.3",

View File

@ -21,8 +21,8 @@ dependencies:
specifier: ^3.0.7 specifier: ^3.0.7
version: 3.0.7 version: 3.0.7
'@push.rocks/smartstream': '@push.rocks/smartstream':
specifier: ^3.0.26 specifier: ^3.0.27
version: 3.0.26 version: 3.0.27
'@push.rocks/smartunique': '@push.rocks/smartunique':
specifier: ^3.0.6 specifier: ^3.0.6
version: 3.0.6 version: 3.0.6
@ -747,7 +747,7 @@ packages:
'@push.rocks/smartpath': 5.0.11 '@push.rocks/smartpath': 5.0.11
'@push.rocks/smartpromise': 4.0.3 '@push.rocks/smartpromise': 4.0.3
'@push.rocks/smartrequest': 2.0.21 '@push.rocks/smartrequest': 2.0.21
'@push.rocks/smartstream': 3.0.26 '@push.rocks/smartstream': 3.0.27
'@types/fs-extra': 11.0.3 '@types/fs-extra': 11.0.3
'@types/glob': 8.1.0 '@types/glob': 8.1.0
'@types/js-yaml': 4.0.8 '@types/js-yaml': 4.0.8
@ -964,8 +964,8 @@ packages:
through2: 4.0.2 through2: 4.0.2
dev: true dev: true
/@push.rocks/smartstream@3.0.26: /@push.rocks/smartstream@3.0.27:
resolution: {integrity: sha512-SJXrKnOMQFFL4a/K/b6z+yR05klWZ2KjuS5HqL/HD0kU5Xi/+bfuKyuNdOV+/BWBRwK03HKH4qnf1kbqPleZXA==} resolution: {integrity: sha512-ZIYYS/dVQab+BP2LIP4u4uUn1oqvRvb/vPUabirhyBJwF8VBYC3ssDp9P+oYcuZ3i+Od0G4g1GQuhtFWNv6hgw==}
dependencies: dependencies:
'@push.rocks/lik': 6.0.12 '@push.rocks/lik': 6.0.12
'@push.rocks/smartpromise': 4.0.3 '@push.rocks/smartpromise': 4.0.3

View File

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

View File

@ -49,13 +49,17 @@ export function unbzip2Stream() {
} catch (e) { } catch (e) {
console.error(e); console.error(e);
broken = true; broken = true;
return false;
} }
}; };
let counter = 0;
return new plugins.smartstream.SmartDuplex({ return new plugins.smartstream.SmartDuplex({
objectMode: true,
// writableObjectMode: true,
name: 'bzip2',
debug: true,
highWaterMark: 1,
writeFunction: async function (data, streamTools) { writeFunction: async function (data, streamTools) {
//console.error('received', data.length,'bytes in', typeof data); console.log(`got chunk ${counter++}`)
bufferQueue.push(data); bufferQueue.push(data);
hasBytes += data.length; hasBytes += data.length;
if (bitReader === null) { if (bitReader === null) {
@ -66,6 +70,10 @@ export function unbzip2Stream() {
while (!broken && hasBytes - bitReader.bytesRead + 1 >= (25000 + 100000 * blockSize || 4)) { while (!broken && hasBytes - bitReader.bytesRead + 1 >= (25000 + 100000 * blockSize || 4)) {
//console.error('decompressing with', hasBytes - bitReader.bytesRead + 1, 'bytes in buffer'); //console.error('decompressing with', hasBytes - bitReader.bytesRead + 1, 'bytes in buffer');
const result = await decompressAndPush(); const result = await decompressAndPush();
if (!result) {
continue;
}
// console.log(result.toString());
await streamTools.push(result); await streamTools.push(result);
} }
}, },
@ -73,11 +81,10 @@ export function unbzip2Stream() {
//console.error(x,'last compressing with', hasBytes, 'bytes in buffer'); //console.error(x,'last compressing with', hasBytes, 'bytes in buffer');
while (!broken && bitReader && hasBytes > bitReader.bytesRead) { while (!broken && bitReader && hasBytes > bitReader.bytesRead) {
const result = await decompressAndPush(); const result = await decompressAndPush();
streamTools.push(result); await streamTools.push(result);
} }
if (!broken) { if (!broken) {
if (streamCRC !== null) this.emit('error', new Error('input stream ended prematurely')); 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 return this.smartArchiveRef.tarTools.getDecompressionStream(); // replace with your own tar decompression stream
default: default:
// Handle unsupported formats or no decompression needed // Handle unsupported formats or no decompression needed
return new plugins.smartstream.PassThrough(); return plugins.smartstream.createPassThrough();
} }
} }
public getAnalyzedStream() { public getAnalyzedStream() {
let firstRun = true; let firstRun = true;
const resultStream = new plugins.smartstream.PassThrough(); const resultStream = plugins.smartstream.createPassThrough();
const analyzerstream = new plugins.smartstream.SmartDuplex<Buffer, IAnalyzedResult>({ const analyzerstream = new plugins.smartstream.SmartDuplex<Buffer, IAnalyzedResult>({
readableObjectMode: true, readableObjectMode: true,
writeFunction: async (chunkArg: Buffer, streamtools) => { writeFunction: async (chunkArg: Buffer, streamtools) => {
@ -63,8 +63,7 @@ export class ArchiveAnalyzer {
resultStream, resultStream,
decompressionStream, decompressionStream,
}; };
streamtools.push(result); await streamtools.push(result);
streamtools.push(null);
return null; return null;
} }
}, },