diff --git a/server/services/DownloadMatcher.js b/server/services/DownloadMatcher.js index 09c719a..3aaf259 100644 --- a/server/services/DownloadMatcher.js +++ b/server/services/DownloadMatcher.js @@ -290,7 +290,7 @@ async function matchSabSlots(slots, context) { const matched = []; for (const slot of slots) { - const nzbName = slot.filename || slot.nzbname; + const nzbName = slot.filename || slot.nzbname || slot.name || slot.nzb_name; if (!nzbName) continue; const slotState = getSlotStatusAndSpeed(slot, queueStatus, queueSpeed, queueKbpersec); @@ -347,7 +347,7 @@ async function matchSabHistory(slots, context) { const matched = []; for (const slot of slots) { - const nzbName = slot.name || slot.nzb_name || slot.nzbname; + const nzbName = slot.filename || slot.nzbname || slot.name || slot.nzb_name; if (!nzbName) continue; const sabDownloadId = slot.nzo_id || slot.id; diff --git a/tests/unit/services/DownloadMatcher.test.js b/tests/unit/services/DownloadMatcher.test.js index 038470e..4d20705 100644 --- a/tests/unit/services/DownloadMatcher.test.js +++ b/tests/unit/services/DownloadMatcher.test.js @@ -263,6 +263,24 @@ describe('DownloadMatcher', () => { expect(result[0].arrQueueId).toBe(301); expect(result[0].arrType).toBe('radarr'); }); + + it('matches when history slots only have the filename field (cached legacy format)', async () => { + const testContext = { + ...context, + sonarrHistoryRecords: [], + sonarrQueueRecords: [ + { id: 201, seriesId: 1, title: 'My.Cool.Show.S01E01.720p-Group' } + ], + seriesMap: new Map([[1, { id: 1, title: 'My Cool Show', tags: [1] }]]) + }; + + const slots = [{ id: null, filename: 'My_Cool_Show_S01E01_720p-Group.nzb', status: 'Completed', mb: 1000 }]; + const result = await DownloadMatcher.matchSabHistory(slots, testContext); + + expect(result).toHaveLength(1); + expect(result[0].arrQueueId).toBe(201); + expect(result[0].arrType).toBe('sonarr'); + }); }); describe('titleMatches helper', () => {