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

Fix symlink behaviour on kqueue #524

Merged
merged 1 commit into from
Jul 12, 2023
Merged

Fix symlink behaviour on kqueue #524

merged 1 commit into from
Jul 12, 2023

Commits on Jul 12, 2023

  1. Fix symlink behaviour on kqueue

    There were two problems here:
    
    - When we see a link inside a directory the resolved version would get
      added to w.watches etc. but the link won't, resulting in many spurious
      create events for the link. This fixes #277; I'm surprised there
      aren't more reports for this).
    
    - filepath.EvalSymlinks() will resolve any symlinks in the entire path,
      rather than just the link itself. This would cause paths such as:
    
          /path/to/LINK/dir/dir/WATCH-THIS
    
      To have the wrong Event.Name; many of the test cases failed because of
      this because /tmp is a link to /private/tmp on macOS, but curiously no
      one reported it AFAIK (I guess many people don't use symlinks all that
      much).
    
      Example:
    
          % mkdir /tmp/xxx
          % touch /tmp/xxx/FILE
    
          % ln -s /tmp/xxx/LINK /tmp/xxx/FILE   # 25 years of Unix experience, and still...
          ln: /tmp/xxx/FILE: File exists
          % ln -s /tmp/xxx/FILE /tmp/xxx/LINK
    
      Before it would do:
    
          % go run ./cmd/fsnotify watch /tmp/xxx &
          % touch /tmp/xxx/FILE
          03:23:03.2731   1 CHMOD         "/private/tmp/xxx/FILE"
          03:23:03.2744   2 CHMOD         "/tmp/xxx/FILE"
          ^C
    
          % fsnotify watch /tmp/xxx/LINK &
          % touch /tmp/xxx/LINK
          03:26:37.3576   1 CHMOD         "/private/tmp/xxx/FILE"
    
      And now it does:
    
          % go run ./cmd/fsnotify watch /tmp/xxx &
          03:23:47.8911   1 CHMOD         "/tmp/xxx/FILE"
          ^C
    
          % fsnotify watch /tmp/xxx/LINK &
          % touch /tmp/xxx/LINK
          03:27:38.5227   1 CHMOD         "/tmp/xxx/FILE"
    arp242 committed Jul 12, 2023
    Configuration menu
    Copy the full SHA
    93c9e6d View commit details
    Browse the repository at this point in the history