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

INotifyWatcher::watch returns an error if any subdirectories contain a broken link. #47

Closed
maurizi opened this issue Dec 26, 2015 · 6 comments

Comments

@maurizi
Copy link
Contributor

maurizi commented Dec 26, 2015

This came up on my project: maurizi/retag.rs#23

From what I can tell, because follow_links(true) is called here, WalkDir returns the target path of symlinks, even if they are broken links. Then when we pass the path over to inotify, it correctly returns an error.

@passcod I can think of a couple of ways to fix this.

  • Each item returned by WalkDir could be tested to see that it exists before calling add_watch
  • Ignore some errors (IO errors like file does not exist) returned by add_watch when calling it from add_watch_recursively
  • Ignore all errors returned by add_watch when calling it from add_watch_recursively

What do you think?

@passcod
Copy link
Member

passcod commented Dec 26, 2015

Ah, I'd have thought the immediate next part in the code (that ignores errors in the lookup) would have solved this. I think the simple thing would just be to completely ignore broken symlinks, at the WalkDir level at least.

I'm idly wondering how this all behaves on other platforms that have symlinks (OS X)... does FSEvent just ignore broken symlinks itself? Hmm.

@maurizi maurizi changed the title INotifyWatcher::watch returns an error if any subdirectories contain a broken link. INotifyWatcher::watch returns an error if any subdirectories contain a broken link. Dec 26, 2015
@maurizi
Copy link
Contributor Author

maurizi commented Dec 26, 2015

Maybe the best way to fix this is to remove the call to follow_symlinks and then call WalkDir again for every symlink found, if it is a valid symlink.

That would also allow rsnotify to watch for changes to the symlink itself, which would be a nice bonus.

@maurizi
Copy link
Contributor Author

maurizi commented Dec 26, 2015

@passcod if you have a preference for how to fix this, I'd be happy to work on a PR.

@passcod
Copy link
Member

passcod commented Dec 26, 2015

Yep, your last proposition sounds good. If you want to work on it, even more awesome :)

@maurizi
Copy link
Contributor Author

maurizi commented Dec 27, 2015

So..... I think I had this all wrong. The way that DirEntry::path() works, it always returns the symlink's path, not it's target (as is noted in the documentation for WalkDir http://burntsushi.net/rustdoc/walkdir/struct.DirEntry.html#method.path).

So actually everything is working? I think perhaps the original issue reported on my project may have been for a different OS than linux...

Anyways, sorry for the non-bug.

@maurizi maurizi closed this as completed Dec 27, 2015
@passcod
Copy link
Member

passcod commented Dec 27, 2015

No problem, thanks for investigating!

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