read files cache from cache directory
(self)
| 531 | return discover_files_cache_names(path, self.FILES_CACHE_NAME) |
| 532 | |
| 533 | def _read_files_cache(self): |
| 534 | """read files cache from cache directory""" |
| 535 | if "d" in self.cache_mode: # d(isabled) |
| 536 | return |
| 537 | |
| 538 | files = {} |
| 539 | logger.debug("Reading files cache ...") |
| 540 | files_cache_logger.debug("FILES-CACHE-LOAD: starting...") |
| 541 | msg = None |
| 542 | try: |
| 543 | with IntegrityCheckedFile( |
| 544 | path=str(self.path / self.files_cache_name()), |
| 545 | write=False, |
| 546 | integrity_data=self.cache_config.integrity.get(self.files_cache_name()), |
| 547 | ) as fd: |
| 548 | u = msgpack.Unpacker(use_list=True) |
| 549 | while True: |
| 550 | data = fd.read(64 * 1024) |
| 551 | if not data: |
| 552 | break |
| 553 | u.feed(data) |
| 554 | try: |
| 555 | for path_hash, entry in u: |
| 556 | entry = FileCacheEntry(*entry) |
| 557 | entry = entry._replace(age=entry.age + 1) |
| 558 | try: |
| 559 | files[path_hash] = self.compress_entry(entry) |
| 560 | except KeyError: |
| 561 | # repo is missing a chunk referenced from entry |
| 562 | logger.debug(f"compress_entry failed for {entry}, skipping.") |
| 563 | except (TypeError, ValueError) as exc: |
| 564 | msg = "The files cache seems invalid. [%s]" % str(exc) |
| 565 | break |
| 566 | except OSError as exc: |
| 567 | msg = "The files cache can't be read. [%s]" % str(exc) |
| 568 | except FileIntegrityError as fie: |
| 569 | msg = "The files cache is corrupted. [%s]" % str(fie) |
| 570 | if msg is not None: |
| 571 | logger.debug(msg) |
| 572 | files = None |
| 573 | files_cache_logger.debug("FILES-CACHE-LOAD: finished, %d entries loaded.", len(files or {})) |
| 574 | return files |
| 575 | |
| 576 | def _write_files_cache(self, files): |
| 577 | """write files cache to cache directory""" |
no test coverage detected