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

Function _queue_pending

graphify/watch.py:35–54  ·  view source on GitHub ↗

Append ``changed_paths`` to ``out_dir/.pending_changes`` (one per line). Used by a post-commit hook process that cannot acquire ``_rebuild_lock`` so its change set is not silently dropped (#1059). The lock-holding process drains this file before and after its rebuild and merges the

(out_dir: Path, changed_paths: list[Path])

Source from the content-addressed store, hash-verified

33
34
35def _queue_pending(out_dir: Path, changed_paths: list[Path]) -> None:
36 """Append ``changed_paths`` to ``out_dir/.pending_changes`` (one per line).
37
38 Used by a post-commit hook process that cannot acquire ``_rebuild_lock``
39 so its change set is not silently dropped (#1059). The lock-holding
40 process drains this file before and after its rebuild and merges the
41 contents with its own change set.
42
43 Opened in append mode so concurrent writers do not clobber each other on
44 POSIX; each ``write()`` of a small payload is effectively atomic. A
45 trailing newline is always written so partial-line corruption stays
46 confined to the offending entry and is skipped on drain.
47 """
48 if not changed_paths:
49 return
50 out_dir.mkdir(parents=True, exist_ok=True)
51 pending = out_dir / _PENDING_FILENAME
52 payload = "".join(f"{os.fspath(p)}\n" for p in changed_paths)
53 with open(pending, "a", encoding="utf-8") as fh:
54 fh.write(payload)
55
56
57def _drain_pending(out_dir: Path) -> list[Path]:

Calls 2

writeMethod · 0.80
joinMethod · 0.45