mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 21:57:57 +02:00
fix archive upload to s3
This commit is contained in:
+4
-6
@@ -160,21 +160,19 @@ 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> {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
const toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client);
|
let toS3: ArchiveStreamToS3;
|
||||||
|
|
||||||
let rootFolder = null;
|
|
||||||
(ArchiveStreamToS3 as any).prototype.onEntry = function (
|
(ArchiveStreamToS3 as any).prototype.onEntry = function (
|
||||||
header: any,
|
header: any,
|
||||||
stream: any,
|
stream: any,
|
||||||
next: any
|
next: any
|
||||||
) {
|
) {
|
||||||
if (rootFolder == null) {
|
header.name = header.name.substr(header.name.indexOf("/") + 1);
|
||||||
rootFolder = header.name.substr(0, header.name.indexOf("/") + 1);
|
|
||||||
}
|
|
||||||
header.name = header.name.replace(rootFolder, "");
|
|
||||||
originalArchiveStreamToS3Entry.call(toS3, header, stream, next);
|
originalArchiveStreamToS3Entry.call(toS3, header, stream, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
toS3 = new ArchiveStreamToS3(config.S3_BUCKET, p, this.client);
|
||||||
|
|
||||||
toS3.on("finish", (result) => {
|
toS3.on("finish", (result) => {
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user