fix: support all slot name variations in DownloadMatcher to resolve cached SAB history matching (#74)
Build and Push Docker Image / build (push) Successful in 39s
CI / Tests & coverage (push) Has been cancelled
CI / Swagger Validation & Coverage (push) Has been cancelled
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m14s
CI / Security audit (push) Has been cancelled

This commit is contained in:
2026-05-29 14:51:52 +01:00
parent b2aa4f23fa
commit b2a837b173
2 changed files with 20 additions and 2 deletions
+2 -2
View File
@@ -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;
@@ -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', () => {