"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
union: fix so all integration tests pass
Nick Craig-Wood1b2cc781e564
diff --git a/backend/union/union.go b/backend/union/union.goindex 6db029074..b71331f71 100644--- a/backend/union/union.go+++ b/backend/union/union.go@@ -1,7 +1,6 @@package unionimport (- "errors""fmt""io""path"@@ -13,6 +12,7 @@ import ("github.com/ncw/rclone/fs/config/configmap""github.com/ncw/rclone/fs/config/configstruct""github.com/ncw/rclone/fs/hash"+ "github.com/pkg/errors")// Register with Fs@@ -100,16 +100,23 @@ func (f *Fs) Put(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.// found.func (f *Fs) List(dir string) (entries fs.DirEntries, err error) {set := make(map[string]fs.DirEntry)+ found := falsefor _, remote := range f.remotes {var remoteEntries, err = remote.List(dir)- if err != nil {+ if err == fs.ErrorDirNotFound {continue}+ if err != nil {+ return nil, errors.Wrapf(err, "List failed on %v", remote)+ }+ found = truefor _, remoteEntry := range remoteEntries {set[remoteEntry.Remote()] = remoteEntry}}-+ if !found {+ return nil, fs.ErrorDirNotFound+ }for key := range set {entries = append(entries, set[key])}@@ -121,9 +128,12 @@ func (f *Fs) NewObject(path string) (fs.Object, error) {for i := range f.remotes {var remote = f.remotes[len(f.remotes)-i-1]var obj, err = remote.NewObject(path)- if err != nil {+ if err == fs.ErrorObjectNotFound {continue}+ if err != nil {+ return nil, errors.Wrapf(err, "NewObject failed on %v", remote)+ }return obj, nil}return nil, fs.ErrorObjectNotFound@@ -131,12 +141,11 @@ func (f *Fs) NewObject(path string) (fs.Object, error) {// Precision is the greatest Precision of all remotesfunc (f *Fs) Precision() time.Duration {- var greatestPrecision = time.Second+ var greatestPrecision time.Durationfor _, remote := range f.remotes {- if remote.Precision() <= greatestPrecision {- continue+ if remote.Precision() > greatestPrecision {+ greatestPrecision = remote.Precision()}- greatestPrecision = remote.Precision()}return greatestPrecision}@@ -196,7 +205,14 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {opt: *opt,remotes: remotes,}- var features = (&fs.Features{}).Fill(f)+ var features = (&fs.Features{+ CaseInsensitive: true,+ DuplicateFiles: false,+ ReadMimeType: true,+ WriteMimeType: true,+ CanHaveEmptyDirectories: true,+ BucketBased: true,+ }).Fill(f)for _, remote := range f.remotes {features = features.Mask(remote)}diff --git a/backend/union/union_test.go b/backend/union/union_test.goindex 82a92c7bc..b24ec29bd 100644--- a/backend/union/union_test.go+++ b/backend/union/union_test.go@@ -4,14 +4,15 @@ package union_testimport ("testing"- "github.com/ncw/rclone/backend/local"+ _ "github.com/ncw/rclone/backend/local""github.com/ncw/rclone/fstest/fstests")// TestIntegration runs integration tests against the remotefunc TestIntegration(t *testing.T) {fstests.Run(t, &fstests.Opt{- RemoteName: "TestUnion:",- NilObject: (*local.Object)(nil),+ RemoteName: "TestUnion:",+ NilObject: nil,+ SkipFsMatch: true,})}