]> go.fuhry.dev Git - fsnotify.git/commitdiff
Linux - fix to see create of file after rename
authorChris Howey <chris@howey.me>
Sat, 14 Jul 2012 18:30:49 +0000 (11:30 -0700)
committerChris Howey <chris@howey.me>
Sat, 14 Jul 2012 18:30:49 +0000 (11:30 -0700)
fsnotify.go
fsnotify_linux.go

index 079869993ecd7626d52df38af18382148e20ad11..8e37833124a45d1ed1384ee882332c8f87320d8f 100644 (file)
@@ -30,7 +30,7 @@ func (w *Watcher) purgeEvents() {
                }
 
                if (fsnFlags&FSN_RENAME == FSN_RENAME) && ev.IsRename() {
-                       w.RemoveWatch(ev.Name)
+                       //w.RemoveWatch(ev.Name)
                        sendEvent = true
                }
 
index a0d10b99ffe455253048ef67e323c75aeda5215f..73c9a3c80720e57a12488983ef01756d2832a888 100644 (file)
@@ -36,7 +36,9 @@ func (e *FileEvent) IsModify() bool {
 }
 
 // IsRename reports whether the FileEvent was triggerd by a change name
-func (e *FileEvent) IsRename() bool { return (e.mask & IN_MOVE_SELF) == IN_MOVE_SELF }
+func (e *FileEvent) IsRename() bool {
+       return ((e.mask&IN_MOVE_SELF) == IN_MOVE_SELF || (e.mask&IN_MOVED_FROM) == IN_MOVED_FROM)
+}
 
 type watch struct {
        wd    uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
@@ -247,7 +249,7 @@ const (
        IN_MOVE_SELF     uint32 = syscall.IN_MOVE_SELF
        IN_OPEN          uint32 = syscall.IN_OPEN
 
-       OS_AGNOSTIC_EVENTS = IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVE_SELF | IN_DELETE | IN_DELETE_SELF
+       OS_AGNOSTIC_EVENTS = IN_MOVED_FROM | IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVE_SELF | IN_DELETE | IN_DELETE_SELF
 
        // Special events
        IN_ISDIR      uint32 = syscall.IN_ISDIR