-
Notifications
You must be signed in to change notification settings - Fork 130
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
rm dir actions triggered two remove event #183
Comments
@JK-97 What OS is that? Can you build your application with debug tag and run it again? |
my os is ubuntu 16.04 |
@JK-97 Yes and no, if you rm -rf then you're going to receive remove events for each deleted dir and file, but you shouldn't receive duplicated events on the same channel if you registered the channel only once. The debug output I mentioned above could shed some light what's happening. |
Seams to be a bug with the inotify implementation: package main
import (
"github.com/rjeczalik/notify"
"github.com/davecgh/go-spew/spew"
)
func main() {
events := make(chan notify.EventInfo, 10)
if err := notify.Watch("/tmp/test/...", events, notify.Remove); err != nil {
panic(err.Error())
}
for event := range events {
spew.Dump(event)
}
} action: /tmp/test/$ mkdir a
/tmp/test/$ rmdir a log:
on:
Seams to only happen for folder removal though both |
OK so inotify gets a rouge package main
import (
"github.com/davecgh/go-spew/spew"
"github.com/rjeczalik/notify"
)
func main() {
events := make(chan notify.EventInfo, 10)
if err := notify.Watch("/tmp/test/...", events, notify.Remove, notify.Rename); err != nil {
panic(err.Error())
}
for event := range events {
spew.Dump(event)
spew.Dump(event.Sys())
}
} actions:
log:
|
name := event.Event().String()
mask := event.Sys().(*unix.InotifyEvent).Mask
if name == "notify.Rename" && (mask&unix.IN_MOVE_SELF) != 0 {
continue
} else if name == "notify.Remove" && (mask&unix.IN_DELETE_SELF) != 0 {
continue
} Seams to give the correct effect. Not a fix though. |
mycode
my watchpath is /edge/...
when i rm aa dir
but the log is:
INFO[0018] create/edge/mnt/aa
WARN[0020] remove/edge/mnt/aa
WARN[0020] remove/edge/mnt/aa
The text was updated successfully, but these errors were encountered: