justinrubek / async-watcher

A file notification library for tokio
MIT License
7 stars 2 forks source link

Watcher only watch once #14

Open liketoeatcheese opened 3 months ago

liketoeatcheese commented 3 months ago

Hey mate,

I'm not sure why this happens but when I modify a file, I only receive the first event. I would assume I should be seeing events every time the file is modified?

Steps to reproduce

git clone ... ; cd async-watcher

touch test.log

vim examples/simple/src/main.rs

let paths = ["test.log"];

cargo run --bin example-simple

vim test.log edit the file and save

This should create an event, like so:

modified: ["/home/user/async-watcher/test.log"]

edit the file again, and you should receive nothing.

Expected behaviour

Receive another modify event

liketoeatcheese commented 3 months ago

Update: It's because when Vim edits it, it replaces the file under the hood and creates a remove file event, which won't produce any extra events because the file it's watching has already been removed.