fix issues with 2,000,000 files being uploaded

This commit is contained in:
tiefseetauchner 2024-08-15 23:10:23 +02:00
parent 3a03667a44
commit 72dc676cb8

View File

@ -127,7 +127,11 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
while (retries < maxRetries) {
try {
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: results } });
const chunks = chunk(results, 1000);
await Promise.all(
chunks.map(async (chunk) => {
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: chunk } });
for (const { id: filepath, assetId, action } of response.results) {
if (action === Action.Accept) {
@ -137,7 +141,8 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
duplicates.push({ id: assetId as string, filepath });
}
}
}),
);
break;
} catch (error: any) {
retries++;