From a100b1a1c02ba540fea14ed42a12d8166814d18c Mon Sep 17 00:00:00 2001 From: Nathan Youngman Date: Sat, 28 Jun 2014 18:47:45 -0600 Subject: [PATCH] Don't set the Write Op for attribute notifications closes #4 --- fsnotify_bsd.go | 2 +- fsnotify_linux.go | 2 +- fsnotify_test.go | 4 ++-- fsnotify_windows.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 8dd51e9..dcb14da 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -32,7 +32,7 @@ func newEvent(name string, mask uint32, create bool) Event { if mask&syscall.NOTE_DELETE == syscall.NOTE_DELETE { e.Op |= Remove } - if mask&syscall.NOTE_WRITE == syscall.NOTE_WRITE || mask&syscall.NOTE_ATTRIB == syscall.NOTE_ATTRIB { + if mask&syscall.NOTE_WRITE == syscall.NOTE_WRITE { e.Op |= Write } if mask&syscall.NOTE_RENAME == syscall.NOTE_RENAME { diff --git a/fsnotify_linux.go b/fsnotify_linux.go index 5e0d0f9..e6ccb48 100644 --- a/fsnotify_linux.go +++ b/fsnotify_linux.go @@ -28,7 +28,7 @@ func newEvent(name string, mask uint32) Event { if mask&syscall.IN_DELETE_SELF == syscall.IN_DELETE_SELF || mask&syscall.IN_DELETE == syscall.IN_DELETE { e.Op |= Remove } - if mask&syscall.IN_MODIFY == syscall.IN_MODIFY || mask&syscall.IN_ATTRIB == syscall.IN_ATTRIB { + if mask&syscall.IN_MODIFY == syscall.IN_MODIFY { e.Op |= Write } if mask&syscall.IN_MOVE_SELF == syscall.IN_MOVE_SELF || mask&syscall.IN_MOVED_FROM == syscall.IN_MOVED_FROM { diff --git a/fsnotify_test.go b/fsnotify_test.go index b4240f3..6436561 100644 --- a/fsnotify_test.go +++ b/fsnotify_test.go @@ -916,8 +916,8 @@ func TestFsnotifyAttrib(t *testing.T) { // We expect this event to be received almost immediately, but let's wait 500 ms to be sure // Creating/writing a file changes also the mtime, so IsAttrib should be set to true here time.Sleep(500 * time.Millisecond) - if modifyReceived.value() == 0 { - t.Fatal("fsnotify modify events have not received after 500 ms") + if modifyReceived.value() != 0 { + t.Fatal("received an unexpected modify event when creating a test file") } if attribReceived.value() == 0 { t.Fatal("fsnotify attribute events have not received after 500 ms") diff --git a/fsnotify_windows.go b/fsnotify_windows.go index 0d559c8..b2d3771 100644 --- a/fsnotify_windows.go +++ b/fsnotify_windows.go @@ -47,7 +47,7 @@ func newEvent(name string, mask uint32) Event { if mask&sys_FS_DELETE == sys_FS_DELETE || mask&sys_FS_DELETE_SELF == sys_FS_DELETE_SELF { e.Op |= Remove } - if mask&sys_FS_MODIFY == sys_FS_MODIFY || mask&sys_FS_ATTRIB == sys_FS_ATTRIB { + if mask&sys_FS_MODIFY == sys_FS_MODIFY { e.Op |= Write } if mask&sys_FS_MOVE == sys_FS_MOVE || mask&sys_FS_MOVE_SELF == sys_FS_MOVE_SELF || mask&sys_FS_MOVED_FROM == sys_FS_MOVED_FROM || mask&sys_FS_MOVED_TO == sys_FS_MOVED_TO { -- 2.50.1