"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 error handling broken by removal of github.com/pkg/errors
Nick Craig-Wood96e099d8e70c
diff --git a/backend/union/entry.go b/backend/union/entry.goindex 9142a61a0..1123183d8 100644--- a/backend/union/entry.go+++ b/backend/union/entry.go@@ -82,7 +82,9 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, opmultithread(len(entries), func(i int) {if o, ok := entries[i].(*upstream.Object); ok {err := o.Update(ctx, readers[i], src, options...)- errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)+ }} else {errs[i] = fs.ErrorNotAFile}@@ -101,7 +103,9 @@ func (o *Object) Remove(ctx context.Context) error {multithread(len(entries), func(i int) {if o, ok := entries[i].(*upstream.Object); ok {err := o.Remove(ctx)- errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)+ }} else {errs[i] = fs.ErrorNotAFile}@@ -120,7 +124,9 @@ func (o *Object) SetModTime(ctx context.Context, t time.Time) error {multithread(len(entries), func(i int) {if o, ok := entries[i].(*upstream.Object); ok {err := o.SetModTime(ctx, t)- errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)+ }} else {errs[i] = fs.ErrorNotAFile}diff --git a/backend/union/union.go b/backend/union/union.goindex c3fb2e26b..f26bdd114 100644--- a/backend/union/union.go+++ b/backend/union/union.go@@ -132,7 +132,9 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error {errs := Errors(make([]error, len(upstreams)))multithread(len(upstreams), func(i int) {err := upstreams[i].Rmdir(ctx, dir)- errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)+ }})return errs.Err()}@@ -162,7 +164,9 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {errs := Errors(make([]error, len(upstreams)))multithread(len(upstreams), func(i int) {err := upstreams[i].Mkdir(ctx, dir)- errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)+ }})return errs.Err()}@@ -189,7 +193,9 @@ func (f *Fs) Purge(ctx context.Context, dir string) error {if errors.Is(err, fs.ErrorDirNotFound) {err = nil}- errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)+ }})return errs.Err()}@@ -285,10 +291,14 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,}// Do the Move or CopydstObj, err := do(ctx, srcObj, remote)- if err != nil || dstObj == nil {+ if err != nil {errs[i] = fmt.Errorf("%s: %w", su.Name(), err)return}+ if dstObj == nil {+ errs[i] = fmt.Errorf("%s: destination object not found", su.Name())+ return+ }objs[i] = du.WrapObject(dstObj)// Delete the source object if Copyif duFeatures.Move == nil {@@ -349,7 +359,9 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote stringreturn}err := du.Features().DirMove(ctx, su.Fs, srcRemote, dstRemote)- errs[i] = fmt.Errorf("%s: %w", du.Name()+":"+du.Root(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", du.Name()+":"+du.Root(), err)+ }})errs = errs.FilterNil()if len(errs) == 0 {@@ -777,7 +789,9 @@ func (f *Fs) Shutdown(ctx context.Context) error {u := f.upstreams[i]if do := u.Features().Shutdown; do != nil {err := do(ctx)- errs[i] = fmt.Errorf("%s: %w", u.Name(), err)+ if err != nil {+ errs[i] = fmt.Errorf("%s: %w", u.Name(), err)+ }}})return errs.Err()