fix(downloads): Fix SABnzbd/qBittorrent collision and webhook metrics
All checks were successful
Build and Push Docker Image / build (push) Successful in 46s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m8s
CI / Security audit (push) Successful in 1m33s
CI / Tests & coverage (push) Successful in 1m41s

1. Fixed download client collision:
   - SABnzbd client with id 'i3omb' was being overwritten by qBittorrent
   - Now uses unique key ':' like the arr retrievers

2. Fixed webhook metrics showing 0:
   - instanceName from webhooks is generic ('Sonarr', 'Radarr')
   - Not the configured instance name ('i3omb')
   - Now updates metrics for ALL instances of that type
This commit is contained in:
2026-05-19 21:40:53 +01:00
parent 5159a83475
commit f22dd0d1f6
2 changed files with 17 additions and 8 deletions

View File

@@ -247,10 +247,14 @@ router.post('/sonarr', webhookLimiter, (req, res) => {
logToFile(`[Webhook] Sonarr payload: ${JSON.stringify(req.body)}`);
// Phase 5.1: update webhook metrics for polling optimization
// Note: instanceName from webhook is often generic (e.g., "Sonarr"), not the configured name
// Update metrics for all Sonarr instances since we can't reliably match
const sonarrInstances = getSonarrInstances();
const instance = sonarrInstances.find(i => i.name === instanceName);
if (instance) {
cache.updateWebhookMetrics(instance.url);
if (sonarrInstances.length > 0) {
for (const inst of sonarrInstances) {
cache.updateWebhookMetrics(inst.url);
}
logToFile(`[Webhook] Updated metrics for ${sonarrInstances.length} Sonarr instance(s)`);
}
// Phase 2: background cache refresh + SSE broadcast (fire-and-forget)
@@ -296,10 +300,14 @@ router.post('/radarr', webhookLimiter, (req, res) => {
logToFile(`[Webhook] Radarr payload: ${JSON.stringify(req.body)}`);
// Phase 5.1: update webhook metrics for polling optimization
// Note: instanceName from webhook is often generic (e.g., "Radarr"), not the configured name
// Update metrics for all Radarr instances since we can't reliably match
const radarrInstances = getRadarrInstances();
const instance = radarrInstances.find(i => i.name === instanceName);
if (instance) {
cache.updateWebhookMetrics(instance.url);
if (radarrInstances.length > 0) {
for (const inst of radarrInstances) {
cache.updateWebhookMetrics(inst.url);
}
logToFile(`[Webhook] Updated metrics for ${radarrInstances.length} Radarr instance(s)`);
}
// Phase 2: background cache refresh + SSE broadcast (fire-and-forget)