Update the cache file.
(cache: Cache, sources: Iterable[Path], mode: Mode)
| 82 | |
| 83 | |
| 84 | def write_cache(cache: Cache, sources: Iterable[Path], mode: Mode) -> None: |
| 85 | """Update the cache file.""" |
| 86 | cache_file = get_cache_file(mode) |
| 87 | try: |
| 88 | CACHE_DIR.mkdir(parents=True, exist_ok=True) |
| 89 | new_cache = { |
| 90 | **cache, |
| 91 | **{str(src.resolve()): get_cache_info(src) for src in sources}, |
| 92 | } |
| 93 | with tempfile.NamedTemporaryFile(dir=str(cache_file.parent), delete=False) as f: |
| 94 | pickle.dump(new_cache, f, protocol=4) |
| 95 | os.replace(f.name, cache_file) |
| 96 | except OSError: |
| 97 | pass |
no test coverage detected