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

Receiving Modify(Metadata(Any)) only if file contents becomes empty from non-empty #564

Open
kwonoj opened this issue Feb 10, 2024 · 2 comments

Comments

@kwonoj
Copy link

kwonoj commented Feb 10, 2024

System details

  • OS/Platform name and version: Mac OS 14.2.1
  • Rust version (if building from source): rustc --version: 1.7.6
  • Notify version (or commit hash if building from git): main branch, or 6.1.1 published
  • 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:
  • On Linux: Kernel version:
  • On Windows: version and if you're running under Windows, Cygwin (unsupported), Linux Subsystem:
  • If you're running as a privileged user (root, System):
  • If you're running in a container, details on the runtime and overlay:
  • If you're running in a VM, details on the hypervisor:

What you did (as detailed as you can)

I'm trying to observing file event around file changes, one thing I noticed is if the change is clearing file to make it empty, I receive Metadata event without Data(Change). Below's a steps I tried

  • Create a file under under ${some_path}, with random contents. Used filename : error.js
'use client'

export default function Error() {}
  • Run cargo run --example monitor_debounced ${some_path} to run repo's example
  • While watcher is running, open file via editor (vscode)
code ${some_path}/error.js
  • ctrl-a, del to clear contents of the file, then ctrl-s
  • Observe event from the watcher
[2024-02-10T05:56:25Z INFO  monitor_debounced] DebouncedEvent { event: Event { kind: Modify(Metadata(Any)), paths: ["${some_path}/error-file/error.js"], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None }, time: Instant { tv_sec: 778788, tv_nsec: 133946541 } }

As long as file contains any characters, watcher emits Modify(Data(Content)) alongside other event so it can be an indication to know file has been modified.

What you expected

  1. Is this expected behavior that empty file won't trigger data event?
  2. If so, is there a recommended way to detect it as modified other then rely on metadata::any event?

What happened

Only metadata event is being emitted if file becomes empty.

@kwonoj
Copy link
Author

kwonoj commented Feb 10, 2024

Actually this seems somewhat intermittent, trying multiple input -> clear sometimes it receives modified::data.

@0xpr03
Copy link
Member

0xpr03 commented Mar 28, 2024

I think I'm missing a step in your experiment, right now I'm not sure what the issue is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants