-
-
Notifications
You must be signed in to change notification settings - Fork 962
Closed
Description
Please describe the issue that occurred.
While watching a directory that contains symbolic links, creating, deleting, or renaming a file or directory inside the watched directory generates spurious CREATE events for all of the symlinks.
Version info:
$ grep fsnotify go.sum
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Which operating system (GOOS) and version are you using?
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.2
BuildVersion: 18C54
$ go version
go version go1.11.4 darwin/amd64
Repro Instructions
Setup:
$ mkdir repro; cd repro; go mod init repro
$ goimports > watchme.go <<EOF
package main
import (
"flag"
"log"
"github.com/fsnotify/fsnotify"
)
func main() {
flag.Parse()
if flag.NArg() != 1 {
log.Fatal("Usage: watchme <path>")
}
w, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal("New: ", err)
}
defer w.Close()
if err := w.Add(flag.Arg(0)); err != nil {
log.Fatalf("Add %q: %v", flag.Arg(0), err)
}
for {
select {
case evt, ok := <-w.Events:
if !ok {
return
}
log.Printf("EVENT: %v", evt)
case err, ok := <-w.Errors:
if !ok {
return
}
log.Printf("ERROR: %v", err)
}
}
}
EOF
$ ln -s go.mod a; ln -s go.sum b
$ go run . .
In another terminal:
$ cd repro
$ touch foo
$ rm foo
$ mkdir apple
$ mv apple pear
$ rmdir pear
Expected (modulo log timestamps):
2018/12/31 15:38:21 EVENT: "foo": CREATE
2018/12/31 15:38:21 EVENT: "foo": REMOVE
2018/12/31 15:38:21 EVENT: "apple": CREATE
2018/12/31 15:38:21 EVENT: "pear": CREATE
2018/12/31 15:38:21 EVENT: "apple": REMOVE|RENAME
2018/12/31 15:38:21 EVENT: "pear": REMOVE
Observed (modulo log timestamps):
2018/12/31 15:39:05 EVENT: "a": CREATE
2018/12/31 15:39:05 EVENT: "b": CREATE
2018/12/31 15:39:05 EVENT: "foo": CREATE
2018/12/31 15:39:05 EVENT: "foo": REMOVE
2018/12/31 15:39:05 EVENT: "a": CREATE
2018/12/31 15:39:05 EVENT: "b": CREATE
2018/12/31 15:39:05 EVENT: "a": CREATE
2018/12/31 15:39:05 EVENT: "apple": CREATE
2018/12/31 15:39:05 EVENT: "b": CREATE
2018/12/31 15:39:05 EVENT: "a": CREATE
2018/12/31 15:39:05 EVENT: "b": CREATE
2018/12/31 15:39:05 EVENT: "pear": CREATE
2018/12/31 15:39:05 EVENT: "apple": REMOVE|RENAME
2018/12/31 15:39:05 EVENT: "pear": REMOVE
2018/12/31 15:39:05 EVENT: "a": CREATE
2018/12/31 15:39:05 EVENT: "b": CREATE
It's worth noting that the events for the test probes are correct, it's just that they're stippled with incorrect spam from the symlinks.
piotrpio