From 74010a1ebde60a9a290ae09629c044a38d24db34 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Dec 2025 15:40:17 +0000 Subject: [PATCH] Improve logging for qBittorrent category creation The 409 (Conflict) status code from qBittorrent's createCategory endpoint means 'category already exists', which is expected behavior, not an error. Previously, the full error object was logged with console.log(), making it look like an error in the logs when it's actually normal operation. Changes: - Check for 409 status code specifically - Log friendly message: 'Category already exists' for 409 - Only log unexpected errors with console.warn - Cleaner logs that don't alarm users The flow still works correctly: 1. Try createCategory (succeeds if new, 409 if exists) 2. Always editCategory to update save path to match current config 3. Both operations complete successfully --- src/lib/integrations/qbittorrent.service.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/integrations/qbittorrent.service.ts b/src/lib/integrations/qbittorrent.service.ts index c6812cb..963b965 100644 --- a/src/lib/integrations/qbittorrent.service.ts +++ b/src/lib/integrations/qbittorrent.service.ts @@ -393,10 +393,15 @@ export class QBittorrentService { } ); - console.log(`[qBittorrent] Category "${category}" created/exists`); + console.log(`[qBittorrent] Category "${category}" created`); } catch (error) { - // Category might already exist - that's OK - console.log(`[qBittorrent] Category creation returned:`, error); + // 409 = category already exists (expected, not an error) + if (axios.isAxiosError(error) && error.response?.status === 409) { + console.log(`[qBittorrent] Category "${category}" already exists`); + } else { + // Unexpected error, but don't fail - editCategory below will handle it + console.warn(`[qBittorrent] Failed to create category:`, error); + } } // Always update the category's save path to ensure it matches current config