fix(watch): reload ignore rules when an ignore file changes (#5033)

The ignored predicate is built at startup. Rebuild it and reschedule the
tree when .graphifyignore or .gitignore changes, so a newly ignored
directory stops being watched and a newly unignored one starts.
This commit is contained in:
Deepjyoti-Sarmah committed 2026-11-08 19:02:26 +05:30
1 parent cf36ca04d4
commit 509df2b391
1 file changed
+11
+11
View File
@@ -3612,6 +3612,7 @@ def watch(watch_path: Path, debounce: float = 3.0) -> None:
class Handler(FileSystemEventHandler):
def on_any_event(self, event):
nonlocal last_trigger, pending, override_snapshot, config_changed
nonlocal ignore_patterns, ignored
if event.is_directory:
if not _is_read_only_event(event):
path = Path(os.fsdecode(event.src_path)).resolve()
@@ -3632,6 +3633,16 @@ def watch(watch_path: Path, debounce: float = 3.0) -> None:
path = Path(os.fsdecode(event.src_path))
if path.parent not in watched or not path.parent.exists():
return
if path.name in {".graphifyignore", ".gitignore"}:
ignore_patterns = _load_graphifyignore(
watch_root_for_ignore, gitignore=ignore_gitignore
)
ignored = ignored_predicate(
watch_root_for_ignore, gitignore=ignore_gitignore
)
remove_tree(watch_root_for_ignore)
add_tree(watch_root_for_ignore, emit_existing=False)
return
# Atomic replacement reports the new root config in dest_path.
dest_raw = getattr(event, "dest_path", None)
dest_path = Path(os.fsdecode(dest_raw)) if dest_raw else None