mirror of
https://github.com/syncthing/notify.git
synced 2026-06-07 08:57:32 +00:00
readdcw: add support for recursive <-> non-recursive rewatching (fixes #66)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user