mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	wip
This commit is contained in:
		| @@ -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: | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user