add todos

This commit is contained in:
tiefseetauchner 2024-08-15 20:25:30 +02:00
parent 5c9ef5c6fd
commit 8e130a6e3e
2 changed files with 15 additions and 7 deletions

View File

@ -190,6 +190,8 @@ describe('checkForDuplicates', () => {
});
});
// TODO: this shouldn't return empty arrays, this should return an error
// Failed duplicate checks should be a reason for panic instead of ignoring
it('returns results when check duplicates retry is failed', async () => {
vi.mocked(checkBulkUpload).mockRejectedValue(new Error('Network error'));

View File

@ -122,14 +122,20 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
const newFiles: string[] = [];
const duplicates: Asset[] = [];
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: results } });
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 });
// TODO: Retry 3 times if there is an error
try {
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: results } });
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 });
}
}
} catch (error: any) {
throw new Error(`An error occurred while checking for duplicates: ${error.message}`);
}
progressBar.stop();