Skip to content

Commit

Permalink
fix: fixed support for file renaming in follow mode on macos (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus authored Oct 29, 2024
1 parent c331d12 commit 914fc31
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/fsmon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 914fc31

Please sign in to comment.