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

Errors when watcher backend is given broken symlinks #21

Closed
sunng87 opened this issue Jul 6, 2015 · 3 comments
Closed

Errors when watcher backend is given broken symlinks #21

sunng87 opened this issue Jul 6, 2015 · 3 comments

Comments

@sunng87
Copy link

sunng87 commented Jul 6, 2015

I'm on Linux kernel 4.1.0, rsnotify 2.1.0 and Emacs 24.5.

My code is as simple as:

fn _watch (p: &Path) -> Result<(), Error>{
    let (tx, rx) = channel();
    let mut watcher: RecommendedWatcher = try!(Watcher::new(tx));
    println!("watcher init");
    try!(watcher.watch(p));
    println!("watching");
    let _ = rx.recv();
    Ok(())
}

Every time I modified files in Emacs, watcher.watch(p) returns error:

Io(Error { repr: Os { code: 2, message: "No such file or directory" } })

If I ls -al the watched directory, I'm getting:

 $ ls -al examples/templates  
drwxr-xr-x 2 nsun nsun 4096 Jul  6 21:04 .
drwxr-xr-x 3 nsun nsun 4096 Jul  4 10:37 ..
lrwxrwxrwx 1 nsun nsun   31 Jul  6 21:04 .#index.hbs -> nsun@thinkless.17462:1435199339
-rw-r--r-- 1 nsun nsun  279 Jul  6 20:57 index.hbs

The .#index.hbs symbol link, as the SO question said, is Emacs lockfile.

I'm not quite sure if this is an rsnotify issue, anything suggestion or workaround are welcomed.

@JIghtuse
Copy link

JIghtuse commented Dec 4, 2015

It also happens if watcher.watch encounters broken symlink. Try to create one and you will see the same result. rsnotify just takes what walker gives it and throws it into add_watch(). What should it do instead?

@passcod
Copy link
Member

passcod commented Dec 5, 2015

It should probably check that the path it's given is a directory or a regular file, and if it's a symlink it should attempt to dereference it, and only feed it to the watcher if either of those is the case. I imagine rsnotify also fails if invoked on, say, "special" files in /dev, /sys, or /proc.

@passcod passcod changed the title Getting error when working with emacs lockfile, Linux Errors when watcher backend is given broken symlinks Dec 5, 2015
passcod added a commit that referenced this issue Dec 6, 2015
Fixes #31
Might help with #17 and #21
passcod added a commit that referenced this issue Dec 7, 2015
Fixes #31
Might help with #17 and #21
passcod added a commit that referenced this issue Dec 7, 2015
Fixes #31
Might help with #17 and #21
@passcod
Copy link
Member

passcod commented Dec 21, 2015

Fix shipped in v2.5.2.

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

No branches or pull requests

3 participants