From 1e2676df264844bddb23f04d2cc9603c1ff707e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=B6ller?= Date: Sun, 7 Oct 2018 11:13:37 +0200 Subject: [PATCH] union: fix ChangeNotify to support multiple remotes To correctly support multiple remotes, each remote has to receive a value on the input channel. --- backend/union/union.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/union/union.go b/backend/union/union.go index 07002446c..0d572ee4e 100644 --- a/backend/union/union.go +++ b/backend/union/union.go @@ -152,11 +152,26 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error { // regulary. When the channel gets closed, the implemantion // should stop polling and release resources. func (f *Fs) ChangeNotify(fn func(string, fs.EntryType), ch <-chan time.Duration) { + var remoteChans []chan time.Duration + for _, remote := range f.remotes { if ChangeNotify := remote.Features().ChangeNotify; ChangeNotify != nil { + ch := make(chan time.Duration) + remoteChans = append(remoteChans, ch) ChangeNotify(fn, ch) } } + + go func() { + for i := range ch { + for _, c := range remoteChans { + c <- i + } + } + for _, c := range remoteChans { + close(c) + } + }() } // DirCacheFlush resets the directory cache - used in testing