Skip to content
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

Spurious delete event on new file #500

Open
inferiorhumanorgans opened this issue Jun 25, 2023 · 4 comments
Open

Spurious delete event on new file #500

inferiorhumanorgans opened this issue Jun 25, 2023 · 4 comments
Labels
A-bug B-unconfirmed Needs verification (by maintainer or testing party) os-mac Z-help wanted

Comments

@inferiorhumanorgans
Copy link

System details

  • OS/Platform name and version: Darwin Kernel Version 18.7.0: Tue Jun 22 19:37:08 PDT 2021; root:xnu-4903.278.70~1/RELEASE_X86_64
  • Rust version (if building from source): rustc --version: rustc 1.72.0-nightly (fe7454bf4 2023-06-19)
  • If you're coming from a project that makes use of Notify, what it is, and a link to the downstream issue if there is one:
  • Filesystem type and options: APFS, encrypted

What you did (as detailed as you can)

notify = { version = "6", features = [ "macos_fsevent" ], default-features = false }
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (tx, rx) = std::sync::mpsc::channel();

    let mut watcher = notify::recommended_watcher(tx)?;

    watcher.watch(Path::new("empty-directory"), RecursiveMode::Recursive)?;

    for res in rx {
        match res {
            Ok(event) => println!("changed: {:?}", event),
            Err(e) => println!("watch error: {:?}", e),
        }
    }

    Ok(())
}

With the example running:

touch empty-directory/newfile

What you expected

changed: Event { kind: Create(File), paths: ["empty-directory/newfile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }

What happened

changed: Event { kind: Create(File), paths: ["empty-directory/newfile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }
changed: Event { kind: Remove(File), paths: ["empty-directory/newfile"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }

Note: this appears to work as expected with the kqueue back end. Things also seem to work as expected if the directory already has files in it when the program is launched.

@0xpr03 0xpr03 added os-mac B-unconfirmed Needs verification (by maintainer or testing party) A-bug labels Jun 26, 2023
@0xpr03
Copy link
Member

0xpr03 commented Jun 26, 2023

So it happens with fseven, but not kqueue ?
And if I get this right: the folder already exists, the file doesn't. And it happens only when you then run "touch" on the non-existing file ?

@inferiorhumanorgans
Copy link
Author

Yep. To add fuel to the fire, the pattern seems to be:

make directory
run program
touch file
works normally
quit program
remove file
run program
touch same file
continues to work abnormally with that file only

@0xpr03
Copy link
Member

0xpr03 commented Jul 12, 2023

Note: someone with macos will have to debug this.

@pstmps
Copy link

pstmps commented Jan 16, 2024

Hi, for what its worth, the above code works fine on
22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64 x86_64
using
rustc 1.75.0 (82e1608df 2023-12-21)
and
Filesystem type and options: APFS, encrypted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug B-unconfirmed Needs verification (by maintainer or testing party) os-mac Z-help wanted
Projects
None yet
Development

No branches or pull requests

3 participants