From 1566def362881fd70ec87b46e87ac744148994a5 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Wed, 18 Feb 2026 15:23:53 -0800 Subject: [PATCH] silence stale download log spam --- web_server.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/web_server.py b/web_server.py index f2cf35e1..01c4dff3 100644 --- a/web_server.py +++ b/web_server.py @@ -4289,15 +4289,23 @@ def get_download_status(): _orphaned_download_keys.discard(context_key) continue # Skip normal post-processing either way + # Skip downloads we've already processed (prevents log spam) + if context_key in _processed_download_ids: + continue + with matched_context_lock: context = matched_downloads_context.get(context_key) - if context: - print(f"✅ [Context Lookup] Found context for key: {context_key}") - else: - print(f"⚠️ [Context Lookup] No context found for key: {context_key}") - print(f" Available keys: {list(matched_downloads_context.keys())[:5]}...") # Show first 5 keys + available_keys = list(matched_downloads_context.keys())[:5] if not context else None - if context and context_key not in _processed_download_ids: + if context: + print(f"✅ [Context Lookup] Found context for key: {context_key}") + elif context_key not in _stale_transfer_keys: + # Only log once per stale key to avoid spamming every poll cycle + print(f"⚠️ [Context Lookup] No context found for key: {context_key}") + print(f" Available keys: {available_keys}...") + _stale_transfer_keys.add(context_key) + + if context: download_dir = docker_resolve_path(config_manager.get('soulseek.download_path', './downloads')) # Use the new robust file finder (only search downloads for post-processing candidates) found_result = _find_completed_file_robust(download_dir, filename_from_api) @@ -9610,6 +9618,10 @@ def _post_process_matched_download(context_key, context, file_path): # Keep track of processed downloads to avoid re-processing _processed_download_ids = set() +# Track stale transfer keys (completed in slskd but no context — e.g., from before app restart) +# so we only log the warning once per key instead of spamming every poll cycle +_stale_transfer_keys = set() + # Per-context-key locks to prevent two threads from processing the same file simultaneously. # Without this, the Stream Processor and Verification Worker race to move the same source file, # and the loser gets a FileNotFoundError because the winner already moved it.