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

Function _stat_entry_for

graphify/cache.py:330–347  ·  view source on GitHub ↗

Get-or-reset the index entry for ``abs_key`` and stamp when it was read. Reuses the existing dict when the stat signature still matches, so co-located values (other salts' digests, ``word_count``) survive; resets it otherwise, so a stale ``word_count`` cannot outlive the content it coun

(abs_key: str, st: "os.stat_result", observed_at_ns: int)

Source from the content-addressed store, hash-verified

328
329
330def _stat_entry_for(abs_key: str, st: "os.stat_result", observed_at_ns: int) -> dict:
331 """Get-or-reset the index entry for ``abs_key`` and stamp when it was read.
332
333 Reuses the existing dict when the stat signature still matches, so
334 co-located values (other salts' digests, ``word_count``) survive; resets it
335 otherwise, so a stale ``word_count`` cannot outlive the content it counted.
336
337 ``observed_at_ns`` must be the clock reading taken *before* the content was
338 read — see :func:`_stat_sig_fresh` for why the ordering matters.
339 """
340 entry = _stat_index.get(abs_key)
341 if (not isinstance(entry, dict)
342 or entry.get("size") != st.st_size
343 or entry.get("mtime_ns") != st.st_mtime_ns):
344 entry = {"size": st.st_size, "mtime_ns": st.st_mtime_ns}
345 _stat_index[abs_key] = entry
346 entry["indexed_at_ns"] = observed_at_ns
347 return entry
348
349
350def _stat_key_to_relative(key: str, anchor: Path) -> str:

Callers 3

file_hashFunction · 0.85
cached_word_countFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected