union: fix ChangeNotify to support multiple remotes

To correctly support multiple remotes, each remote has to receive a
value on the input channel.
This commit is contained in:
Fabian Möller 2018-10-07 11:13:37 +02:00
parent 364fca5cea
commit 1e2676df26

View File

@ -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