fix(cli): only act on files that were sent in the bulk upload check (#32564)

(cherry picked from commit 9e20805e21c72b95f8c23f4985c8a20b4c3da12a)
This commit is contained in:
bo0tzz
2026-10-22 05:21:00 +03:00
committed by Codex
parent c66634fcfd
commit 7df744b684
2 changed files with 39 additions and 0 deletions
+33
View File
@@ -200,6 +200,39 @@ describe('checkForDuplicates', () => {
});
});
it('ignores accepted files that were not part of the request', async () => {
vi.mocked(checkBulkUpload).mockResolvedValue({
results: [
{ action: AssetUploadAction.Accept, id: testFilePath },
{ action: AssetUploadAction.Accept, id: '/etc/passwd' },
],
});
await expect(checkForDuplicates([testFilePath], { concurrency: 1 })).resolves.toEqual({
duplicates: [],
newFiles: [testFilePath],
});
});
it('ignores rejected files that were not part of the request', async () => {
vi.mocked(checkBulkUpload).mockResolvedValue({
results: [
{ action: AssetUploadAction.Accept, id: testFilePath },
{
action: AssetUploadAction.Reject,
id: '/etc/passwd',
assetId: 'fc5621b1-86f6-44a1-9905-403e607df9f5',
reason: AssetRejectReason.Duplicate,
},
],
});
await expect(checkForDuplicates([testFilePath], { concurrency: 1 })).resolves.toEqual({
duplicates: [],
newFiles: [testFilePath],
});
});
it('returns results when check duplicates retry is successful', async () => {
let mocked = vi.mocked(checkBulkUpload);
for (let i = 1; i < retry; i++) {
+6
View File
@@ -232,8 +232,14 @@ export const checkForDuplicates = async (files: string[], { concurrency, skipHas
const response = await checkBulkUpload({ assetBulkUploadCheckDto: { assets } });
const results = response.results as AssetBulkUploadCheckResults;
const requested = new Set(assets.map(({ id }) => id));
for (const { id: filepath, assetId, action } of results) {
if (!requested.has(filepath)) {
console.warn(`Ignoring unexpected file in bulk upload check response: ${filepath}`);
continue;
}
if (action === AssetUploadAction.Accept) {
newFiles.push(filepath);
} else {