mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:06:56 -04:00
fix tests
This commit is contained in:
parent
8e130a6e3e
commit
3a03667a44
@ -190,14 +190,11 @@ describe('checkForDuplicates', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: this shouldn't return empty arrays, this should return an error
|
it('throws error when check duplicates retry is failed', async () => {
|
||||||
// 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'));
|
vi.mocked(checkBulkUpload).mockRejectedValue(new Error('Network error'));
|
||||||
|
|
||||||
await expect(checkForDuplicates([testFilePath], { concurrency: 1 })).resolves.toEqual({
|
await expect(checkForDuplicates([testFilePath], { concurrency: 1 })).rejects.toThrowError(
|
||||||
duplicates: [],
|
'An error occurred while checking for duplicates: Network error',
|
||||||
newFiles: [],
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -122,7 +122,10 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
|
|||||||
const newFiles: string[] = [];
|
const newFiles: string[] = [];
|
||||||
const duplicates: Asset[] = [];
|
const duplicates: Asset[] = [];
|
||||||
|
|
||||||
// TODO: Retry 3 times if there is an error
|
let retries = 0;
|
||||||
|
const maxRetries = 3;
|
||||||
|
|
||||||
|
while (retries < maxRetries) {
|
||||||
try {
|
try {
|
||||||
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: results } });
|
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets: results } });
|
||||||
|
|
||||||
@ -134,9 +137,15 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
|
|||||||
duplicates.push({ id: assetId as string, filepath });
|
duplicates.push({ id: assetId as string, filepath });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
retries++;
|
||||||
|
if (retries >= maxRetries) {
|
||||||
throw new Error(`An error occurred while checking for duplicates: ${error.message}`);
|
throw new Error(`An error occurred while checking for duplicates: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
progressBar.stop();
|
progressBar.stop();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user