-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PollWatcher panics if a watched file is removed and recreated. #359
Labels
Comments
jhscheer
changed the title
Both the raw PollWatcher and the debounced PollWatcher panic if a watched file is removed and recreated. (4.0.1.7)
PollWatcher panics if a watched file is removed and recreated.
Sep 18, 2021
This code can reproduce bug. //! # Dependencies
//!
//! ```toml
//! [dependencies]
//! notify = "5.0.0-pre.15"
//! ```
//!
//! # Test
//!
//! Panic with following shell command.
//!
//! ```sh
//! # in first terminal
//! touch mew.txt
//! cargo run
//!
//! # in second terminal
//! rm mew.txt && sleep 1 && touch mew.txt
//! ```
use notify::Watcher;
use std::{thread, time::Duration};
fn main() {
let mut watcher = notify::PollWatcher::with_config(
|event| println!("{event:?}"),
notify::poll::PollWatcherConfig {
poll_interval: Duration::from_secs(1),
..Default::default()
},
)
.unwrap();
watcher
.watch("mew.txt".as_ref(), notify::RecursiveMode::Recursive)
.unwrap();
thread::park();
} Output:
|
visig9
added a commit
to visig9/notify
that referenced
this issue
May 18, 2022
See notify-rs#359 for more detail.
I create #406 to fix. After this PR, the previous test code should output: Err(Error { kind: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" }), paths: ["mew.txt"] })
Ok(Event { kind: Remove(Any), paths: ["mew.txt"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None })
Ok(Event { kind: Create(Any), paths: ["mew.txt"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }) |
visig9
added a commit
to visig9/notify
that referenced
this issue
May 18, 2022
See notify-rs#359 for more detail.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
System details
rustc --version
: 1.54.0What you did (as detailed as you can)
Run above code to monitor
testfile
, then run:Both the raw PollWatcher and the debounced PollWatcher panic if a watched file is remove and recreated.
Edit:
Same issue exists on
5.0.0-pre.13
:What you expected
What happened
The text was updated successfully, but these errors were encountered: