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,17 +127,22 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
while (retries < maxRetries) { while (retries < maxRetries) {
try { try {
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: results } }); const chunks = chunk(results, 1000);
for (const { id: filepath, assetId, action } of response.results) { await Promise.all(
if (action === Action.Accept) { chunks.map(async (chunk) => {
newFiles.push(filepath); const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: chunk } });
} else {
// rejects are always duplicates
duplicates.push({ id: assetId as string, filepath });
}
}
for (const { id: filepath, assetId, action } of response.results) {
if (action === Action.Accept) {
newFiles.push(filepath);
} else {
// rejects are always duplicates
duplicates.push({ id: assetId as string, filepath });
}
}
}),
);
break; break;
} catch (error: any) { } catch (error: any) {
retries++; retries++;