From 58cecff7783fa24205f632909bf7dd638071c7ce Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 19 Oct 2025 14:44:04 -1000 Subject: [PATCH] wip --- esphome/github_cache.py | 8 ++++---- esphome/platformio_api.py | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/esphome/github_cache.py b/esphome/github_cache.py index 90aaab3f92..e0308745ea 100644 --- a/esphome/github_cache.py +++ b/esphome/github_cache.py @@ -89,7 +89,7 @@ class GitHubCache: etag: ETag header from previous response Returns: - True if modified (or unable to check), False if not modified + True if modified, False if not modified (or offline/unreachable) """ if not last_modified and not etag: # No cache headers available, assume modified @@ -115,9 +115,9 @@ class GitHubCache: return False # Other errors, assume modified to be safe return True - except (OSError, urllib.error.URLError) as e: - # If check fails, assume not modified (use cache) - _LOGGER.debug("Failed to check if modified: %s", e) + except (OSError, urllib.error.URLError): + # If check fails (offline/network error), assume not modified (use cache) + _LOGGER.info("Cannot reach server (offline?), using cached file: %s", url) return False def get_cached_path(self, url: str, check_updates: bool = True) -> Path | None: diff --git a/esphome/platformio_api.py b/esphome/platformio_api.py index fe6aed442a..9c5c08e86d 100644 --- a/esphome/platformio_api.py +++ b/esphome/platformio_api.py @@ -99,7 +99,7 @@ def patch_file_downloader(): from os.path import join self._destination = join(dest_dir, self._fname) - _LOGGER.info("Using cached download for %s", url) + # Note: Actual restoration logged in patched_start return None # Don't call original_init # Normal initialization with retry logic @@ -132,6 +132,9 @@ def patch_file_downloader(): if cached_file: try: shutil.copy2(cached_file, self._destination) + _LOGGER.info( + "Restored %s from cache (avoided download)", Path(cached_file).name + ) return True except OSError as e: _LOGGER.warning("Failed to copy from cache: %s", e)