diff --git a/py/services/downloader.py b/py/services/downloader.py index 1be64542..71360538 100644 --- a/py/services/downloader.py +++ b/py/services/downloader.py @@ -22,6 +22,7 @@ from typing import Optional, Dict, Tuple, Callable, Union, Awaitable from ..services.settings_manager import get_settings_manager from .connectivity_guard import ( OFFLINE_COOLDOWN_ERROR, + OFFLINE_FRIENDLY_MESSAGE, ConnectivityGuard, ) from .errors import RateLimitError @@ -803,7 +804,7 @@ class Downloader: """ guard = await ConnectivityGuard.get_instance() if guard.should_block_request(): - return False, OFFLINE_COOLDOWN_ERROR, None + return False, OFFLINE_FRIENDLY_MESSAGE, None try: session = await self.session @@ -849,7 +850,7 @@ class Downloader: if guard.is_network_unreachable_error(e): guard.register_network_failure(e) if guard.should_block_request(): - return False, OFFLINE_COOLDOWN_ERROR, None + return False, OFFLINE_FRIENDLY_MESSAGE, None logger.debug("Network unavailable during memory download: %s", e) return False, str(e), None logger.error(f"Error downloading to memory from {url}: {e}") diff --git a/tests/services/test_connectivity_guard.py b/tests/services/test_connectivity_guard.py index 66a9bb6a..321837eb 100644 --- a/tests/services/test_connectivity_guard.py +++ b/tests/services/test_connectivity_guard.py @@ -6,6 +6,7 @@ import pytest from py.services.connectivity_guard import ( OFFLINE_COOLDOWN_ERROR, + OFFLINE_FRIENDLY_MESSAGE, ConnectivityGuard, ) from py.services.downloader import Downloader @@ -66,7 +67,7 @@ async def test_downloader_short_circuits_all_request_helpers_during_cooldown(): ok, payload, headers = await downloader.download_to_memory("https://example.invalid") assert ok is False - assert payload == OFFLINE_COOLDOWN_ERROR + assert payload == OFFLINE_FRIENDLY_MESSAGE assert headers is None ok, payload = await downloader.get_response_headers("https://example.invalid")