pub struct Watches { /* private fields */ }Expand description
The native watches a root holds, and the reconciler’s handle on them.
Two kinds, tracked apart because they are retired by different rules:
- tree directories, armed one at a time when
per_diris set. A recursive inotify watch is a descriptor per directory whether or not the sync mirrors it, so a filtered sync of a checkout would still pay fornode_modulesandtarget— the cost the exclusion exists to avoid, and on a big tree the one that hitsfs.inotify.max_user_watches. Arming per directory puts the reconciler in charge: it arms exactly what it indexes, in the order it indexes it, and never reaches the excluded subtrees. The arm-before-list contract holds one level down — a directory is armed before it is read — and these are disarmed as the index drops them. - outside directories, holding ignore sources above the root. No
hint from inside the tree could ever report those, so without them a
parent
.gitignoreedit is invisible for the life of the sync. They are armed once and never retired, since nothing in the index tracks them.
Implementations§
Source§impl Watches
impl Watches
Sourcepub fn add_dir(&self, dir: &Path) -> bool
pub fn add_dir(&self, dir: &Path) -> bool
Arm a tree directory, non-recursively. false only when the
process is out of watch descriptors — the caller closes the root,
because a mirror with an unwatched directory in it is silently
stale. Every other failure (the directory vanished mid-scan,
permission) returns true: there is nothing to watch, and nothing
to mirror either.
Sourcepub fn watch_outside(&self, dir: &Path)
pub fn watch_outside(&self, dir: &Path)
Arm a directory outside the tree because it holds an ignore source. Failure is not fatal the way a tree directory’s is: the rules were already read, and the only loss is noticing a later edit — the behavior every sync had before these were watched at all.
Sourcepub fn is_per_dir(&self) -> bool
pub fn is_per_dir(&self) -> bool
Whether the tree is watched a directory at a time rather than by one recursive watch on the root.
Sourcepub fn remove_dir(&self, dir: &Path)
pub fn remove_dir(&self, dir: &Path)
Disarm dir and everything under it — a deleted or newly excluded
subtree. inotify drops the kernel watch on deletion by itself; this
is what keeps the bookkeeping (and notify’s own map) from growing
across a create/delete cycle.
Sourcepub fn retain_dirs(&self, keep: &dyn Fn(&Path) -> bool)
pub fn retain_dirs(&self, keep: &dyn Fn(&Path) -> bool)
Drop every armed tree directory keep rejects. Used after a full
rescan, which replaces the index wholesale and so cannot report
individual removals — the one place a whole-set pass is the right
shape, since every entry has to be reconsidered anyway.