fix(network): restore destination-scoped memory download guard

This commit is contained in:
Will Miao
2026-04-20 18:27:38 +08:00
parent 89e26d9292
commit 1eeba666f5

View File

@@ -804,7 +804,8 @@ class Downloader:
Tuple[bool, Union[bytes, str], Optional[Dict]]: (success, content or error message, response headers if requested) Tuple[bool, Union[bytes, str], Optional[Dict]]: (success, content or error message, response headers if requested)
""" """
guard = await ConnectivityGuard.get_instance() guard = await ConnectivityGuard.get_instance()
if guard.should_block_request(): destination = self._guard_destination(url)
if guard.should_block_request(destination):
return False, OFFLINE_FRIENDLY_MESSAGE, None return False, OFFLINE_FRIENDLY_MESSAGE, None
try: try:
@@ -849,8 +850,8 @@ class Downloader:
except Exception as e: except Exception as e:
if guard.is_network_unreachable_error(e): if guard.is_network_unreachable_error(e):
guard.register_network_failure(e) guard.register_network_failure(e, destination)
if guard.should_block_request(): if guard.should_block_request(destination):
return False, OFFLINE_FRIENDLY_MESSAGE, None return False, OFFLINE_FRIENDLY_MESSAGE, None
logger.debug("Network unavailable during memory download: %s", e) logger.debug("Network unavailable during memory download: %s", e)
return False, str(e), None return False, str(e), None