MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _settle

Function _settle

tests/test_word_count_cache.py:13–23  ·  view source on GitHub ↗

Backdate mtime past the racily-clean window so the stat fastpath is allowed to serve this file. A just-written file is deliberately never trusted: its mtime tick may still be open, so a same-length rewrite could hide behind an identical (size, mtime_ns). See cache._stat_sig_fresh. A

(path: Path)

Source from the content-addressed store, hash-verified

11
12
13def _settle(path: Path) -> None:
14 """Backdate mtime past the racily-clean window so the stat fastpath is
15 allowed to serve this file.
16
17 A just-written file is deliberately never trusted: its mtime tick may still
18 be open, so a same-length rewrite could hide behind an identical
19 (size, mtime_ns). See cache._stat_sig_fresh. Any test asserting a warm stat
20 hit therefore has to settle the file first.
21 """
22 old = path.stat().st_mtime_ns - 10 * 1_000_000_000
23 os.utime(path, ns=(old, old))
24
25
26def test_word_count_cached_until_file_changes(tmp_path, monkeypatch):

Calls

no outgoing calls

Tested by

no test coverage detected