Fix false positive Soulseek connection test by checking network state

main
Broque Thomas 2 days ago
parent 2c56b23c27
commit 7726e86a78

@ -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:

@ -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."
}

Loading…
Cancel
Save