vendor: Update github.com/syncthing/notify (fixes #4885) (#4894)

This commit is contained in:
Simon Frei
2018-04-20 17:01:03 +02:00
committed by GitHub
parent 25bf406f0e
commit 3d02fcd473
6 changed files with 40 additions and 33 deletions

View File

@@ -93,7 +93,7 @@ func (t *nonrecursiveTree) internal(rec <-chan EventInfo) {
t.rw.Unlock()
continue
}
err := nd.Add(ei.Path()).AddDir(t.recFunc(eset, nil))
err := nd.Add(ei.Path()).AddDir(t.recFunc(eset), nil)
t.rw.Unlock()
if err != nil {
dbgprintf("internal(%p) error: %v", rec, err)
@@ -146,7 +146,7 @@ func (t *nonrecursiveTree) watchDel(nd node, c chan<- EventInfo, e Event) eventD
// Watch TODO(rjeczalik)
func (t *nonrecursiveTree) Watch(path string, c chan<- EventInfo,
doNotWatch func(string) bool, events ...Event) error {
doNotWatch DoNotWatchFn, events ...Event) error {
if c == nil {
panic("notify: Watch using nil channel")
}
@@ -188,8 +188,8 @@ func (t *nonrecursiveTree) watch(nd node, c chan<- EventInfo, e Event) (err erro
return nil
}
func (t *nonrecursiveTree) recFunc(e Event, doNotWatch func(string) bool) walkFunc {
addWatch := func(nd node) (err error) {
func (t *nonrecursiveTree) recFunc(e Event) walkFunc {
return func(nd node) (err error) {
switch diff := nd.Watch.Add(t.rec, e|omit|Create); {
case diff == none:
case diff[1] == 0:
@@ -202,20 +202,11 @@ func (t *nonrecursiveTree) recFunc(e Event, doNotWatch func(string) bool) walkFu
}
return
}
if doNotWatch != nil {
return func(nd node) (err error) {
if doNotWatch(nd.Name) {
return errSkip
}
return addWatch(nd)
}
}
return addWatch
}
func (t *nonrecursiveTree) watchrec(nd node, c chan<- EventInfo, e Event,
doNotWatch func(string) bool) error {
var traverse func(walkFunc) error
doNotWatch DoNotWatchFn) error {
var traverse func(walkFunc, DoNotWatchFn) error
// Non-recursive tree listens on Create event for every recursive
// watchpoint in order to automagically set a watch for every
// created directory.
@@ -236,7 +227,7 @@ func (t *nonrecursiveTree) watchrec(nd node, c chan<- EventInfo, e Event,
}
// TODO(rjeczalik): account every path that failed to be (re)watched
// and retry.
if err := traverse(t.recFunc(e, doNotWatch)); err != nil {
if err := traverse(t.recFunc(e), doNotWatch); err != nil {
return err
}
t.watchAdd(nd, c, e)