| 780 | |
| 781 | |
| 782 | def read_chunkindex_from_repo_cache(repository, hash): |
| 783 | cache_name = f"cache/chunks.{hash}" |
| 784 | logger.debug(f"trying to load {cache_name} from the repo...") |
| 785 | try: |
| 786 | chunks_data = repository.store_load(cache_name) |
| 787 | except StoreObjectNotFound: |
| 788 | logger.debug(f"{cache_name} not found in the repository.") |
| 789 | else: |
| 790 | if xxh64(chunks_data, seed=CHUNKINDEX_HASH_SEED).digest() == hex_to_bin(hash): |
| 791 | logger.debug(f"{cache_name} is valid.") |
| 792 | with io.BytesIO(chunks_data) as f: |
| 793 | chunks = ChunkIndex.read(f) |
| 794 | return chunks |
| 795 | else: |
| 796 | logger.debug(f"{cache_name} is invalid.") |
| 797 | |
| 798 | |
| 799 | def build_chunkindex_from_repo(repository, *, disable_caches=False, cache_immediately=False): |