diff --git a/test/test.ts b/test/test.ts index 40c6d14..52335b4 100644 --- a/test/test.ts +++ b/test/test.ts @@ -35,21 +35,7 @@ tap.test('should extract existing files on disk', async () => { const testSmartarchive = await smartarchive.SmartArchive.fromArchiveUrl( 'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz' ); - const streamfileStream = await testSmartarchive.exportToStreamOfStreamFiles(); - - streamfileStream.pipe(new plugins.smartstream.SmartDuplex({ - objectMode: true, - writeAndTransformFunction: async (chunkArg: plugins.smartfile.StreamFile, streamtools) => { - console.log(chunkArg.relativeFilePath); - const streamFile = chunkArg; - const readStream = await streamFile.createReadStream(); - const writePath = plugins.path.join(testPaths.nogitDir + streamFile.relativeFilePath); - const dir = plugins.path.parse(writePath).dir; - await plugins.smartfile.fs.ensureDir(plugins.path.dirname(dir)); - const writeStream = plugins.smartfile.fsStream.createWriteStream(writePath); - readStream.pipe(writeStream); - }, - })); + const streamfileStream = await testSmartarchive.exportToFs(testPaths.nogitDir); }); tap.start(); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 22b2739..14c22e2 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartarchive', - version: '4.0.1', + version: '4.0.2', description: 'work with archives' } diff --git a/ts/classes.smartarchive.ts b/ts/classes.smartarchive.ts index f8383ec..f702112 100644 --- a/ts/classes.smartarchive.ts +++ b/ts/classes.smartarchive.ts @@ -107,7 +107,8 @@ export class SmartArchive { plugins.smartstream.createTransformFunction( async (analyzedResultChunk) => { if (analyzedResultChunk.fileType.mime === 'application/x-tar') { - (analyzedResultChunk.decompressionStream as plugins.tarStream.Extract).on( + const tarStream = analyzedResultChunk.decompressionStream as plugins.tarStream.Extract; + tarStream.on( 'entry', async (header, stream, next) => { const streamfile = plugins.smartfile.StreamFile.fromStream(stream, header.name); @@ -117,6 +118,9 @@ export class SmartArchive { }); } ); + tarStream.on('finish', function () { + streamFileIntake.signalEnd(); + }) analyzedResultChunk.resultStream.pipe(analyzedResultChunk.decompressionStream); } else if (analyzedResultChunk.isArchive && analyzedResultChunk.decompressionStream) { analyzedResultChunk.resultStream