From b786a816fb72424119ded1dac66d27324e81f4b5 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Fri, 13 Aug 2021 11:51:15 +0200 Subject: [PATCH] fix archive upload to s3 --- src/storage/S3.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/storage/S3.ts b/src/storage/S3.ts index d9b147e..d68df5d 100644 --- a/src/storage/S3.ts +++ b/src/storage/S3.ts @@ -160,21 +160,19 @@ export default class S3Storage implements StorageBase { /** @override */ async extractTar(p: string, data: stream.Readable): Promise { return new Promise((resolve, reject) => { - const toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client); + let toS3: ArchiveStreamToS3; - let rootFolder = null; (ArchiveStreamToS3 as any).prototype.onEntry = function ( header: any, stream: any, next: any ) { - if (rootFolder == null) { - rootFolder = header.name.substr(0, header.name.indexOf("/") + 1); - } - header.name = header.name.replace(rootFolder, ""); + header.name = header.name.substr(header.name.indexOf("/") + 1); originalArchiveStreamToS3Entry.call(toS3, header, stream, next); }; + toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client); + toS3.on("finish", (result) => { resolve(result); });