readdcw: add support for recursive <-> non-recursive rewatching (fixes #66)

This commit is contained in:
Pawel Knap
2015-02-10 15:29:59 +01:00
parent cf85976e54
commit 433face91a
4 changed files with 16 additions and 1 deletions
+8
View File
@@ -7,6 +7,7 @@ package notify
import (
"syscall"
"time"
"unsafe"
)
@@ -23,3 +24,10 @@ func Sync() {
// dbg.Print("SetSystemFileCacheSize error:", err)
// }
}
// UpdateWait pauses the program for some minimal amount of time. This function
// is required only by implementations which work asynchronously. It gives
// watcher structure time to update its internal state.
func UpdateWait() {
time.Sleep(50 * time.Millisecond)
}
+5
View File
@@ -11,3 +11,8 @@ import "syscall"
func Sync() {
syscall.Sync()
}
// UpdateWait is required only by windows watcher implementation. On other
// platforms this function is no-op.
func UpdateWait() {
}
+2
View File
@@ -431,6 +431,7 @@ func drainall(c chan EventInfo) (ei []EventInfo) {
// ExpectAny TODO
func (w *W) ExpectAny(cases []WCase) {
UpdateWait() // Wait some time before starting the test.
Test:
for i, cas := range cases {
dbg.Printf("ExpectAny: i=%d\n", i)
@@ -825,6 +826,7 @@ func (n *N) ExpectTreeEvents(cases []TCase, all Chans) {
// ExpectNotifyEvents TODO(rjeczalik)
func (n *N) ExpectNotifyEvents(cases []NCase, all Chans) {
UpdateWait() // Wait some time before starting the test.
for i, cas := range cases {
dbg.Printf("ExpectNotifyEvents: i=%d\n", i)
cas.Event.Action()
+1 -1
View File
@@ -426,7 +426,7 @@ func (r *readdcw) RecursiveRewatch(oldpath, newpath string, oldevent,
return err
}
return r.watch(newpath, newevent, true)
case oldevent != newevent:
default:
return r.rewatch(newpath, uint32(oldevent), uint32(newevent), true)
}
return nil