fix(core): update

This commit is contained in:
Philipp Kunz 2024-06-08 11:01:56 +02:00
parent f99f6d96c5
commit a3ecfe4d99
2 changed files with 17 additions and 14 deletions

View File

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

View File

@ -55,6 +55,22 @@ export class TarTools {
contentByteLength = fileStat.size; contentByteLength = fileStat.size;
} }
/**
* here we try to harmonize all kind of entries towards a readable stream
*/
let content: plugins.smartstream.stream.Readable;
if (Buffer.isBuffer(optionsArg.content)) {
content = plugins.smartstream.stream.Readable.from(optionsArg.content);
} else if (typeof optionsArg.content === 'string') {
content = plugins.smartstream.stream.Readable.from(Buffer.from(optionsArg.content));
} else if (optionsArg.content instanceof plugins.smartfile.SmartFile) {
content = plugins.smartstream.stream.Readable.from(optionsArg.content.contents);
} else if (optionsArg.content instanceof plugins.smartfile.StreamFile) {
content = await optionsArg.content.createReadStream();
} else if (optionsArg.content instanceof plugins.smartstream.stream.Readable) {
content = optionsArg.content;
}
const entry = pack.entry( const entry = pack.entry(
{ {
name: fileName, name: fileName,
@ -73,19 +89,6 @@ export class TarTools {
} }
); );
let content: plugins.smartstream.stream.Readable;
if (Buffer.isBuffer(optionsArg.content)) {
content = plugins.smartstream.stream.Readable.from(optionsArg.content);
} else if (typeof optionsArg.content === 'string') {
content = plugins.smartstream.stream.Readable.from(Buffer.from(optionsArg.content));
} else if (optionsArg.content instanceof plugins.smartfile.SmartFile) {
content = plugins.smartstream.stream.Readable.from(optionsArg.content.contents);
} else if (optionsArg.content instanceof plugins.smartfile.StreamFile) {
content = await optionsArg.content.createReadStream();
} else if (optionsArg.content instanceof plugins.smartstream.stream.Readable) {
content = optionsArg.content;
}
content.pipe(entry); content.pipe(entry);
entry.on('end', () => { entry.on('end', () => {
resolve(); resolve();