-
Notifications
You must be signed in to change notification settings - Fork 35
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
document expected behavior for symlinks #18
Comments
Looking into this led me to realize that the behavior for symlinks isn't great, nor is it consistent. The polling watcher treats them effectively the same as their targets, which is probably the most useful option. But I believe the native |
A couple more annoying issues:
|
I don't know if we have a reliable way to detect this. If we do, we could have the polyfill fall back to a polling watcher, but that may be pretty difficult to implement—it's a lot easier if all the event sources are In general, our policy up to this point for non-watchable filesystems has just been to require that the caller (and transitively the user) explicitly specify the polling watcher. This is probably the easiest solution for non-watchable subdirectories as well, at least for now.
Right now the polling watcher just treats them as though they don't exist. Generally we only emit events for files, which broken links sort of are and sort of aren't, so it could go either way, and I don't have a strong preference. On one hand not emitting events means choosing to hide information we have; on the other I'd imagine almost all actual uses are going to assume we're emitting events for real files, won't test with broken links, and will end up breaking if they come up in practice. What's your preference? |
Just for my own documentation, I was playing around with how symlinks work with FSEvents on OS X, and I learned an unpleasant fact: it's possible to create a valid symlink without triggering any events at all, which means we won't even know to create a watcher for the resolved path. To do so, just create a broken symlink in the watched directory. From then on, many changes to that symlink—including creating its target file or even retargeting it to a real file—will not be reported. Removing it will, but by that point it's not particularly useful. Unfortunately this seems to be a fundamental flaw in FSEvents itself, so we can't fix it in |
If the Analyzer or a text editor is the main use case, readable files and directories are what we care about and hiding broken links or other unusual filesystem objects seems better than reporting them. But then there's the question of how to handle a transition - if a symlink used to work, but the file it points to is deleted or replaced with something that's not a regular file, it seems useful to send a "delete" event. Also nice to report "add" for the opposite transition, but it may not be possible. Other unpleasant edge cases, beyond symlinks:
|
If we treat broken links as non-existent, we'll definitely report delete and add events when they're broken or fixed, respectively (except on OS X I guess).
Today we report a DELETE, which I think is correct.
This just closes the stream. It's pretty easy to just open a new one afterwards.
For a directory, we pretend it doesn't exist. For a file, we leave it up to the user to handle gracefully. |
So far this only covers the Linux and polling watchers. See #18 R=rnystrom@google.com Review URL: https://codereview.chromium.org//1406223012 .
I built a simple tool that watches a directory and applies formatting when a file changes ( |
Currently the watcher package is not symlink-aware at all, and the behavior follows whatever the native behavior of |
It's unclear what's supposed to happen for symlinks. We don't need to implement full symlink support, but we should say what happens when they exist.
The text was updated successfully, but these errors were encountered: