(image_id: str | None = None)
| 57 | |
| 58 | |
| 59 | def fingerprint_cache_inputs(image_id: str | None = None) -> str: |
| 60 | def iter_files(path: Path) -> Iterator[Path]: |
| 61 | if path.is_dir(): |
| 62 | for root, dirs, files in os.walk(path): |
| 63 | for f in files: |
| 64 | yield Path(root) / f |
| 65 | else: |
| 66 | yield path |
| 67 | |
| 68 | hashes = { |
| 69 | str(path): hashlib.sha256(path.read_bytes()).hexdigest() |
| 70 | for path in sorted( |
| 71 | itertools.chain.from_iterable(iter_files(cache_input) for cache_input in _CACHE_INPUTS) |
| 72 | ) |
| 73 | } |
| 74 | |
| 75 | return hashlib.sha256( |
| 76 | json.dumps({"image_id": image_id, "hashes": hashes}, sort_keys=True).encode("utf-8") |
| 77 | ).hexdigest() |
| 78 | |
| 79 | |
| 80 | def export_tarball_path(sub_image: str | None = None) -> Path: |
no test coverage detected