From 914fc314741faa0adaf18287c8e4235070265ef4 Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Tue, 29 Oct 2024 22:44:32 +0100 Subject: [PATCH] fix: fixed support for file renaming in follow mode on macos (#511) --- src/fsmon.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/fsmon.rs b/src/fsmon.rs index 84e50271..3827a275 100644 --- a/src/fsmon.rs +++ b/src/fsmon.rs @@ -104,13 +104,14 @@ mod imp { let mut added = HashSet::<&PathBuf>::new(); let mut synced = true; + let flags = FilterFlag::NOTE_FFNOP + | FilterFlag::NOTE_DELETE + | FilterFlag::NOTE_WRITE + | FilterFlag::NOTE_RENAME + | FilterFlag::NOTE_EXTEND; + loop { for path in &paths { - let flags = FilterFlag::NOTE_FFNOP - | FilterFlag::NOTE_DELETE - | FilterFlag::NOTE_WRITE - | FilterFlag::NOTE_RENAME - | FilterFlag::NOTE_EXTEND; if watcher.add_filename(path, EventFilter::EVFILT_VNODE, flags).is_ok() { added.insert(path); if !synced { @@ -153,6 +154,10 @@ mod imp { Event::new(EventKind::Modify(ModifyKind::Data(DataChange::Size))).add_path(path) } Vnode::Rename => { + if added.contains(&path) { + watcher.remove_filename(&path, EventFilter::EVFILT_VNODE)?; + added.remove(&path); + } Event::new(EventKind::Modify(ModifyKind::Name(RenameMode::Any))).add_path(path) } Vnode::Link => Event::new(EventKind::Create(CreateKind::Any)).add_path(path),