Skip to content

Commit

Permalink
file: more precise FileEvent::Remove capture
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Sep 11, 2023
1 parent 485fe7d commit efa69e1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sea-streamer-file/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ impl Watchers {
sender.send((fid.clone(), FileEvent::Modify)).ok();
}
ModifyKind::Metadata(_) => {
// it only shows `Any` on my machine
sender.send((fid.clone(), FileEvent::Remove)).ok();
// we are in a different thread, but blocking here is still undesirable
if std::fs::metadata(fid.path()).is_err() {
sender.send((fid.clone(), FileEvent::Remove)).ok();
}
}
_ => (),
}
Expand All @@ -153,7 +155,7 @@ impl Watchers {
.map_err(|e| FileErr::WatchError(e.to_string()))?;

watcher
.watch(file_id.path().as_ref(), RecursiveMode::Recursive)
.watch(file_id.path().as_ref(), RecursiveMode::NonRecursive)
.map_err(|e| FileErr::WatchError(e.to_string()))?;

Ok(watcher)
Expand Down

0 comments on commit efa69e1

Please sign in to comment.