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

Watch on non-existing file #580

Closed
tisonkun opened this issue Mar 26, 2024 · 3 comments
Closed

Watch on non-existing file #580

tisonkun opened this issue Mar 26, 2024 · 3 comments

Comments

@tisonkun
Copy link

My scenario is to watch a credential file; if not exist, bypass authentication; otherwise read the content to build the map.

I found that if the file exists and later deleted and recreated, all the loading can happen properly. But notify requires the file to exist initially:

    // https://github.com/thibaudgg/rb-fsevent/blob/master/ext/fsevent_watch/main.c
    fn append_path(&mut self, path: &Path, recursive_mode: RecursiveMode) -> Result<()> {
        if !path.exists() {
            return Err(Error::path_not_found().add_path(path.into()));
        }

Since we can anyway delete the file later it starts, I wonder if we can relax this condition (or at lease when RecursiveMode::NonRecursive) so that make it possible to watch on a maybe non-existing file.

cc @0xpr03

@tisonkun
Copy link
Author

Seems it depends on the OS whether events can be emitted - fsnotify/fsnotify#49

@dfaust
Copy link
Collaborator

dfaust commented May 5, 2024

I suggest you watch the parent folder.
Does that work for you?

@tisonkun
Copy link
Author

tisonkun commented May 5, 2024

Yes. This is how I finally worked it out - GreptimeTeam/greptimedb@408f8df (among GreptimeTeam/greptimedb#3566)

@tisonkun tisonkun closed this as completed May 5, 2024
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