notify
notify copied to clipboard
Receiving `Modify(Metadata(Any))` only if file contents becomes empty from non-empty
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):
mainbranch, 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
- Is this expected behavior that empty file won't trigger data event?
- If so, is there a recommended way to detect it as
modifiedother then rely on metadata::any event?
What happened
Only metadata event is being emitted if file becomes empty.
Actually this seems somewhat intermittent, trying multiple input -> clear sometimes it receives modified::data.
I think I'm missing a step in your experiment, right now I'm not sure what the issue is.