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

Add option to disable following symlinks #227

Open
adriansr opened this issue Dec 11, 2017 · 3 comments
Open

Add option to disable following symlinks #227

adriansr opened this issue Dec 11, 2017 · 3 comments
Labels

Comments

@adriansr
Copy link

Which operating system (GOOS) and version are you using?

GOOS: darwin
ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G1036

Please describe the issue that occurred.

Under macOS, fsnotify follows symlinks on watched directories and produces notifications for changes to files residing on directories pointed by the symlink.

Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.

  1. The usual watcher / logger:
package main

import (
	"log"

	"github.com/fsnotify/fsnotify"
)

func main() {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	defer watcher.Close()
	err = watcher.Add("/tmp/bug")
	if err != nil {
		log.Fatal(err)
	}
	for {
		select {
		case ev := <-watcher.Events:
			log.Printf("Got event %+v", ev)
		}
	}
}

Operations to perform:

mkdir /tmp/bug
mkdir /tmp/other
ln -s /tmp/other /tmp/bug/link
touch /tmp/other/somefile

Events received:

2017/12/11 23:44:38 Got event "/tmp/bug/link": CREATE
2017/12/11 23:44:41 Got event "/private/tmp/other/somefile": CREATE
@bep
Copy link
Member

bep commented Dec 11, 2017

And this is wrong? Why?

@adriansr
Copy link
Author

@bep I understand the watching is meant not to be recursive?

If instead of linking to another directory, I just create the directory inside a watched directory, I don't get notifications for it. Why would I want symlinks to behave differently?

Also, this behavior is only displayed in macOS. Not Linux or Windows.

@nathany
Copy link
Contributor

nathany commented Oct 5, 2019

see #199 and #289.

@arp242 arp242 changed the title fsnotify follows symlinks under macOS Add option to disable following symlinks Apr 28, 2024
arp242 added a commit that referenced this issue May 1, 2024
Option to not follow symlinks, but watch the links themselves.

Unexported for now, until it's supported everywhere.

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

No branches or pull requests

4 participants