mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-09 15:17:49 +02:00
fix: improve S3 reliability
This commit is contained in:
@@ -106,7 +106,9 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const downloadStream = got.stream(response.url);
|
const downloadStream = got.stream(response.url);
|
||||||
downloadStream.addListener("downloadProgress", (p) => (progress = p));
|
downloadStream.addListener("downloadProgress", async (p) => {
|
||||||
|
progress = p;
|
||||||
|
});
|
||||||
await storage.extractZip(originalPath, downloadStream, undefined, this);
|
await storage.extractZip(originalPath, downloadStream, undefined, this);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.repository.updateStatus(
|
await this.repository.updateStatus(
|
||||||
|
|||||||
+5
-7
@@ -71,10 +71,10 @@ export default class S3Storage implements StorageBase {
|
|||||||
/** @override */
|
/** @override */
|
||||||
async rm(dir: string): Promise<void> {
|
async rm(dir: string): Promise<void> {
|
||||||
if (!config.S3_BUCKET) throw new Error("S3_BUCKET not set");
|
if (!config.S3_BUCKET) throw new Error("S3_BUCKET not set");
|
||||||
const data = await this.client().listObjectsV2({
|
const data = await this.client(200000).listObjectsV2({
|
||||||
Bucket: config.S3_BUCKET,
|
Bucket: config.S3_BUCKET,
|
||||||
Prefix: dir,
|
Prefix: dir,
|
||||||
MaxKeys: 1000,
|
MaxKeys: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
@@ -92,7 +92,7 @@ export default class S3Storage implements StorageBase {
|
|||||||
// nothing to remove
|
// nothing to remove
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.client().deleteObjects(params);
|
await this.client(200000).deleteObjects(params);
|
||||||
|
|
||||||
if (data.IsTruncated) {
|
if (data.IsTruncated) {
|
||||||
await this.rm(dir);
|
await this.rm(dir);
|
||||||
@@ -249,11 +249,9 @@ export default class S3Storage implements StorageBase {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
maxParallel: 10,
|
||||||
});
|
});
|
||||||
pipeline(data, toS3, (err) => {
|
pipeline(data, toS3, () => {})
|
||||||
if (err) reject(err);
|
|
||||||
else resolve();
|
|
||||||
})
|
|
||||||
.on("finish", resolve)
|
.on("finish", resolve)
|
||||||
.on("error", reject);
|
.on("error", reject);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user