From 9ddd9379abf4c874481d0790373af57a74de9379 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 6 Mar 2026 17:43:08 -0600 Subject: [PATCH] Refine VFS watch behavior to support recursive watching - Updated the `read_raw` method in `VfsInner` to ensure that the file watching behavior is only triggered when both `watch_enabled` and `watch_recursive` are true. This change enhances the control over file watching, particularly in scenarios involving nested directories. These modifications aim to improve the efficiency and accuracy of the VFS's file watching capabilities. --- crates/memofs/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/memofs/src/lib.rs b/crates/memofs/src/lib.rs index 8cb973de..12ecd08e 100644 --- a/crates/memofs/src/lib.rs +++ b/crates/memofs/src/lib.rs @@ -179,7 +179,7 @@ impl VfsInner { fn read_raw(&mut self, path: &Path) -> io::Result> { if let Some(cache) = &mut self.prefetch_cache { if let Some(contents) = cache.files.remove(path) { - if self.watch_enabled { + if self.watch_enabled && self.watch_recursive { self.watch_or_record(path)?; } return Ok(contents); @@ -188,7 +188,7 @@ impl VfsInner { let contents = self.backend.read(path)?; - if self.watch_enabled { + if self.watch_enabled && self.watch_recursive { self.watch_or_record(path)?; }