From 8b299222ea9565970915f85a729603b1a77f781d Mon Sep 17 00:00:00 2001 From: tdurieux Date: Wed, 8 Sep 2021 10:27:04 +0200 Subject: [PATCH] fix: fix github download 2 --- src/source/GitHubDownload.ts | 2 +- src/storage/S3.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/source/GitHubDownload.ts b/src/source/GitHubDownload.ts index d5a6b10..e2c38bf 100644 --- a/src/source/GitHubDownload.ts +++ b/src/source/GitHubDownload.ts @@ -89,7 +89,7 @@ export default class GitHubDownload extends GitHubBase implements SourceBase { await storage.extractTar(originalPath, downloadStream); } catch (error) { await this.repository.updateStatus("error", "unable_to_download"); - throw new AnonymousError("unable_to_download"); + throw new AnonymousError("unable_to_download", error); } finally { inDownload = false; clearTimeout(progressTimeout); diff --git a/src/storage/S3.ts b/src/storage/S3.ts index dedcd5a..270e85a 100644 --- a/src/storage/S3.ts +++ b/src/storage/S3.ts @@ -169,8 +169,6 @@ export default class S3Storage implements StorageBase { /** @override */ async extractTar(p: string, data: stream.Readable): Promise { - const pipeline = promisify(stream.pipeline); - let toS3: ArchiveStreamToS3; (ArchiveStreamToS3 as any).prototype.onEntry = function ( @@ -181,10 +179,14 @@ export default class S3Storage implements StorageBase { header.name = header.name.substr(header.name.indexOf("/") + 1); originalArchiveStreamToS3Entry.call(toS3, header, stream, next); }; - - toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client); - - return pipeline(data, gunzip(), toS3); + + return new Promise((resolve, reject) => { + toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client); + stream + .pipeline(data, gunzip(), toS3, () => {}) + .on("finish", resolve) + .on("error", reject); + }); } /** @override */