fix: fix github download 2

This commit is contained in:
tdurieux
2021-09-08 10:27:04 +02:00
parent 8c6bc97cde
commit 8b299222ea
2 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
await storage.extractTar(originalPath, downloadStream); await storage.extractTar(originalPath, downloadStream);
} catch (error) { } catch (error) {
await this.repository.updateStatus("error", "unable_to_download"); await this.repository.updateStatus("error", "unable_to_download");
throw new AnonymousError("unable_to_download"); throw new AnonymousError("unable_to_download", error);
} finally { } finally {
inDownload = false; inDownload = false;
clearTimeout(progressTimeout); clearTimeout(progressTimeout);
+7 -5
View File
@@ -169,8 +169,6 @@ export default class S3Storage implements StorageBase {
/** @override */ /** @override */
async extractTar(p: string, data: stream.Readable): Promise<void> { async extractTar(p: string, data: stream.Readable): Promise<void> {
const pipeline = promisify(stream.pipeline);
let toS3: ArchiveStreamToS3; let toS3: ArchiveStreamToS3;
(ArchiveStreamToS3 as any).prototype.onEntry = function ( (ArchiveStreamToS3 as any).prototype.onEntry = function (
@@ -182,9 +180,13 @@ export default class S3Storage implements StorageBase {
originalArchiveStreamToS3Entry.call(toS3, header, stream, next); originalArchiveStreamToS3Entry.call(toS3, header, stream, next);
}; };
toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client); return new Promise((resolve, reject) => {
toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client);
return pipeline(data, gunzip(), toS3); stream
.pipeline(data, gunzip(), toS3, () => {})
.on("finish", resolve)
.on("error", reject);
});
} }
/** @override */ /** @override */