Skip to content

Commit

Permalink
union: fix ChangeNotify to support multiple remotes
Browse files Browse the repository at this point in the history
To correctly support multiple remotes, each remote has to receive a
value on the input channel.
  • Loading branch information
B4dM4n committed Oct 7, 2018
1 parent 364fca5 commit 1e2676d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backend/union/union.go
Expand Up @@ -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
Expand Down

0 comments on commit 1e2676d

Please sign in to comment.