feat(classes.smartarchive): Support URL web streams, add recursive archive unpacking and filesystem export, and improve ZIP decompression robustness

This commit is contained in:
2025-08-18 01:01:02 +00:00
parent b5a3793ed5
commit a32ed0facd
6 changed files with 85 additions and 4 deletions

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartarchive',
version: '4.0.39',
version: '4.1.0',
description: 'A library for working with archive files, providing utilities for compressing and decompressing data.'
}

View File

@@ -60,7 +60,12 @@ export class SmartArchive {
return this.sourceStream;
}
if (this.sourceUrl) {
const urlStream = await plugins.smartrequest.getStream(this.sourceUrl);
const response = await plugins.smartrequest.SmartRequest.create()
.url(this.sourceUrl)
.get();
const webStream = response.stream();
// @ts-ignore - Web stream to Node.js stream conversion
const urlStream = plugins.stream.Readable.fromWeb(webStream);
return urlStream;
}
if (this.sourceFilePath) {

View File

@@ -19,9 +19,9 @@ class DecompressZipTransform extends plugins.smartstream.SmartDuplex<ArrayBuffer
constructor() {
super({
objectMode: true,
writeFunction: async (chunkArg: Buffer, streamtoolsArg) => {
writeFunction: async (chunkArg, streamtoolsArg) => {
this.streamtools? null : this.streamtools = streamtoolsArg;
this.unzipper.push(chunkArg, false);
this.unzipper.push(Buffer.isBuffer(chunkArg) ? chunkArg : Buffer.from(chunkArg), false);
},
finalFunction: async () => {
this.unzipper.push(Buffer.from(''), true);