fix(core): update
This commit is contained in:
@@ -74,7 +74,7 @@ export class SmartArchive {
|
||||
// return archiveStream;
|
||||
}
|
||||
|
||||
public async exportToFs(targetDir: string): Promise<void> {
|
||||
public async exportToFs(targetDir: string, fileNameArg?: string): Promise<void> {
|
||||
const done = plugins.smartpromise.defer<void>();
|
||||
const streamFileStream = await this.exportToStreamOfStreamFiles();
|
||||
streamFileStream.pipe(new plugins.smartstream.SmartDuplex({
|
||||
@@ -83,14 +83,15 @@ export class SmartArchive {
|
||||
console.log(chunkArg.relativeFilePath);
|
||||
const streamFile = chunkArg;
|
||||
const readStream = await streamFile.createReadStream();
|
||||
const writePath = plugins.path.join(targetDir + streamFile.relativeFilePath);
|
||||
const dir = plugins.path.parse(writePath).dir;
|
||||
await plugins.smartfile.fs.ensureDir(plugins.path.dirname(dir));
|
||||
await plugins.smartfile.fs.ensureDir(targetDir);
|
||||
const writePath = plugins.path.join(targetDir, (streamFile.relativeFilePath || fileNameArg));
|
||||
await plugins.smartfile.fs.ensureDir(plugins.path.dirname(writePath));
|
||||
const writeStream = plugins.smartfile.fsStream.createWriteStream(writePath);
|
||||
readStream.pipe(writeStream).end(() => {
|
||||
done.resolve();
|
||||
});
|
||||
readStream.pipe(writeStream);
|
||||
},
|
||||
finalFunction: async () => {
|
||||
done.resolve();
|
||||
}
|
||||
}));
|
||||
return done.promise;
|
||||
}
|
||||
@@ -106,7 +107,7 @@ export class SmartArchive {
|
||||
const createUnpackStream = () =>
|
||||
plugins.smartstream.createTransformFunction<IAnalyzedResult, any>(
|
||||
async (analyzedResultChunk) => {
|
||||
if (analyzedResultChunk.fileType.mime === 'application/x-tar') {
|
||||
if (analyzedResultChunk.fileType?.mime === 'application/x-tar') {
|
||||
const tarStream = analyzedResultChunk.decompressionStream as plugins.tarStream.Extract;
|
||||
tarStream.on(
|
||||
'entry',
|
||||
@@ -116,11 +117,13 @@ export class SmartArchive {
|
||||
stream.on('end', function () {
|
||||
next(); // ready for next entry
|
||||
});
|
||||
stream.resume(); // just auto drain the stream
|
||||
}
|
||||
);
|
||||
tarStream.on('finish', function () {
|
||||
console.log('finished');
|
||||
streamFileIntake.signalEnd();
|
||||
})
|
||||
});
|
||||
analyzedResultChunk.resultStream.pipe(analyzedResultChunk.decompressionStream);
|
||||
} else if (analyzedResultChunk.isArchive && analyzedResultChunk.decompressionStream) {
|
||||
analyzedResultChunk.resultStream
|
||||
@@ -130,11 +133,11 @@ export class SmartArchive {
|
||||
} else {
|
||||
const streamFile = plugins.smartfile.StreamFile.fromStream(
|
||||
analyzedResultChunk.resultStream,
|
||||
analyzedResultChunk.fileType.ext
|
||||
analyzedResultChunk.fileType?.ext
|
||||
);
|
||||
streamFileIntake.push(streamFile);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
archiveStream.pipe(createAnalyzedStream()).pipe(createUnpackStream());
|
||||
|
Reference in New Issue
Block a user