From 7726e86a78a2d9bf7dc14dff31c5b2e7074cdc39 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Fri, 20 Feb 2026 11:32:52 -0800 Subject: [PATCH] Fix false positive Soulseek connection test by checking network state --- core/soulseek_client.py | 15 +++++++++++++-- web_server.py | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/soulseek_client.py b/core/soulseek_client.py index 7005cc8..36f1f75 100644 --- a/core/soulseek_client.py +++ b/core/soulseek_client.py @@ -1442,11 +1442,22 @@ class SoulseekClient: return await self.download(best_result.username, best_result.filename, best_result.size) async def check_connection(self) -> bool: - """Check if slskd is running and accessible""" + """Check if slskd is running and connected to the Soulseek network""" if not self.base_url: return False - + try: + # Primary check: server/state tells us if slskd is connected to the Soulseek network + state = await self._make_request('GET', 'server/state') + if state is not None: + is_connected = state.get('isConnected') or state.get('IsConnected', False) + is_logged_in = state.get('isLoggedIn') or state.get('IsLoggedIn', False) + if not (is_connected and is_logged_in): + logger.debug(f"Soulseek not fully connected: isConnected={is_connected}, isLoggedIn={is_logged_in}") + return is_connected and is_logged_in + + # Fallback: if server/state endpoint unavailable (older slskd), check API reachability + logger.debug("server/state endpoint unavailable, falling back to session check") response = await self._make_request('GET', 'session') return response is not None except Exception as e: diff --git a/web_server.py b/web_server.py index c749529..c2cf1e6 100644 --- a/web_server.py +++ b/web_server.py @@ -1733,7 +1733,7 @@ def run_service_test(service, test_config): if run_async(soulseek_client.check_connection()): # Success message based on active mode mode_messages = { - 'soulseek': "Successfully connected to slskd.", + 'soulseek': "Successfully connected to Soulseek network via slskd.", 'youtube': "YouTube download source ready.", 'hybrid': "Download sources ready (Hybrid mode)." } @@ -1742,7 +1742,7 @@ def run_service_test(service, test_config): else: # Failure message based on active mode mode_errors = { - 'soulseek': "Could not connect to slskd. Check URL and API Key.", + 'soulseek': "slskd is not connected to the Soulseek network. Check slskd status and credentials.", 'youtube': "YouTube download source not available.", 'hybrid': "Could not connect to download sources. Check configuration." }