"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
cache: fix dedupe on caches wrapping drives - fixes #4320
Nick Craig-Wood7e48ee8758c4
diff --git a/backend/cache/cache.go b/backend/cache/cache.goindex 1a7332721..d06e757ca 100644--- a/backend/cache/cache.go+++ b/backend/cache/cache.go@@ -1829,6 +1829,19 @@ func (f *Fs) isRootInPath(p string) bool {return strings.HasPrefix(p, f.Root()+"/")}+// MergeDirs merges the contents of all the directories passed+// in into the first one and rmdirs the other directories.+func (f *Fs) MergeDirs(ctx context.Context, dirs []fs.Directory) error {+ do := f.Fs.Features().MergeDirs+ if do == nil {+ return errors.New("MergeDirs not supported")+ }+ for _, dir := range dirs {+ _ = f.cache.RemoveDir(dir.Remote())+ }+ return do(ctx, dirs)+}+// DirCacheFlush flushes the dir cachefunc (f *Fs) DirCacheFlush() {_ = f.cache.RemoveDir("")@@ -1926,4 +1939,5 @@ var (_ fs.UserInfoer = (*Fs)(nil)_ fs.Disconnecter = (*Fs)(nil)_ fs.Commander = (*Fs)(nil)+ _ fs.MergeDirser = (*Fs)(nil))diff --git a/backend/cache/cache_test.go b/backend/cache/cache_test.goindex 7f9175861..56a9ba918 100644--- a/backend/cache/cache_test.go+++ b/backend/cache/cache_test.go@@ -18,7 +18,7 @@ func TestIntegration(t *testing.T) {fstests.Run(t, &fstests.Opt{RemoteName: "TestCache:",NilObject: (*cache.Object)(nil),- UnimplementableFsMethods: []string{"PublicLink", "MergeDirs", "OpenWriterAt"},+ UnimplementableFsMethods: []string{"PublicLink", "OpenWriterAt"},UnimplementableObjectMethods: []string{"MimeType", "ID", "GetTier", "SetTier"},SkipInvalidUTF8: true, // invalid UTF-8 confuses the cache})