Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

union: fix ChangeNotify to support multiple remotes

Fabian Möller1e2676df2648
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