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)
| 328 | |
| 329 | |
| 330 | def _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 | |
| 350 | def _stat_key_to_relative(key: str, anchor: Path) -> str: |
no test coverage detected