(cls, *, src: Path)
| 280 | |
| 281 | @classmethod |
| 282 | def proxy(cls, *, src: Path) -> Path: |
| 283 | if cls.get_location() is None: # Caching is disabled |
| 284 | return src |
| 285 | |
| 286 | cache_obj = MirrorJSON(src=src) |
| 287 | |
| 288 | if cache_obj.is_valid: |
| 289 | logger.debug(f"Retrieving package mirror JSON {cache_obj.cid} from cache") |
| 290 | return cache_obj.cache_file_location |
| 291 | |
| 292 | # If the mirror is a mounted network drive (common configuration), this would trigger a network traffic/calls |
| 293 | # We want to prevent any network traffic for performance reasons if possible, |
| 294 | # so we check if the path exists AFTER we check for the cache entry, e.g. `cache_obj.is_valid` |
| 295 | if not src.exists(): |
| 296 | return src |
| 297 | |
| 298 | try: |
| 299 | cache_obj.fetch(src=src) |
| 300 | return cache_obj.cache_file_location |
| 301 | except Exception as exc: |
| 302 | cache_obj.delete() |
| 303 | raise exc |
| 304 | |
| 305 | @property |
| 306 | def metadata(self) -> dict: |
nothing calls this directly
no test coverage detected