mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 11:55:01 +01:00
union: fix error handling broken by removal of github.com/pkg/errors
There were instances of errors.Wrap being called with a nil error which the conversion didn't deal with correctly.
This commit is contained in:
parent
2a31b5bdd6
commit
96e099d8e7
@ -82,7 +82,9 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
multithread(len(entries), func(i int) {
|
multithread(len(entries), func(i int) {
|
||||||
if o, ok := entries[i].(*upstream.Object); ok {
|
if o, ok := entries[i].(*upstream.Object); ok {
|
||||||
err := o.Update(ctx, readers[i], src, options...)
|
err := o.Update(ctx, readers[i], src, options...)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errs[i] = fs.ErrorNotAFile
|
errs[i] = fs.ErrorNotAFile
|
||||||
}
|
}
|
||||||
@ -101,7 +103,9 @@ func (o *Object) Remove(ctx context.Context) error {
|
|||||||
multithread(len(entries), func(i int) {
|
multithread(len(entries), func(i int) {
|
||||||
if o, ok := entries[i].(*upstream.Object); ok {
|
if o, ok := entries[i].(*upstream.Object); ok {
|
||||||
err := o.Remove(ctx)
|
err := o.Remove(ctx)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errs[i] = fs.ErrorNotAFile
|
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) {
|
multithread(len(entries), func(i int) {
|
||||||
if o, ok := entries[i].(*upstream.Object); ok {
|
if o, ok := entries[i].(*upstream.Object); ok {
|
||||||
err := o.SetModTime(ctx, t)
|
err := o.SetModTime(ctx, t)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errs[i] = fs.ErrorNotAFile
|
errs[i] = fs.ErrorNotAFile
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,9 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error {
|
|||||||
errs := Errors(make([]error, len(upstreams)))
|
errs := Errors(make([]error, len(upstreams)))
|
||||||
multithread(len(upstreams), func(i int) {
|
multithread(len(upstreams), func(i int) {
|
||||||
err := upstreams[i].Rmdir(ctx, dir)
|
err := upstreams[i].Rmdir(ctx, dir)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return errs.Err()
|
return errs.Err()
|
||||||
}
|
}
|
||||||
@ -162,7 +164,9 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {
|
|||||||
errs := Errors(make([]error, len(upstreams)))
|
errs := Errors(make([]error, len(upstreams)))
|
||||||
multithread(len(upstreams), func(i int) {
|
multithread(len(upstreams), func(i int) {
|
||||||
err := upstreams[i].Mkdir(ctx, dir)
|
err := upstreams[i].Mkdir(ctx, dir)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return errs.Err()
|
return errs.Err()
|
||||||
}
|
}
|
||||||
@ -189,7 +193,9 @@ func (f *Fs) Purge(ctx context.Context, dir string) error {
|
|||||||
if errors.Is(err, fs.ErrorDirNotFound) {
|
if errors.Is(err, fs.ErrorDirNotFound) {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", upstreams[i].Name(), err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return errs.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 Copy
|
// Do the Move or Copy
|
||||||
dstObj, err := do(ctx, srcObj, remote)
|
dstObj, err := do(ctx, srcObj, remote)
|
||||||
if err != nil || dstObj == nil {
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", su.Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", su.Name(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if dstObj == nil {
|
||||||
|
errs[i] = fmt.Errorf("%s: destination object not found", su.Name())
|
||||||
|
return
|
||||||
|
}
|
||||||
objs[i] = du.WrapObject(dstObj)
|
objs[i] = du.WrapObject(dstObj)
|
||||||
// Delete the source object if Copy
|
// Delete the source object if Copy
|
||||||
if duFeatures.Move == nil {
|
if duFeatures.Move == nil {
|
||||||
@ -349,7 +359,9 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := du.Features().DirMove(ctx, su.Fs, srcRemote, dstRemote)
|
err := du.Features().DirMove(ctx, su.Fs, srcRemote, dstRemote)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", du.Name()+":"+du.Root(), err)
|
errs[i] = fmt.Errorf("%s: %w", du.Name()+":"+du.Root(), err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
errs = errs.FilterNil()
|
errs = errs.FilterNil()
|
||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
@ -777,8 +789,10 @@ func (f *Fs) Shutdown(ctx context.Context) error {
|
|||||||
u := f.upstreams[i]
|
u := f.upstreams[i]
|
||||||
if do := u.Features().Shutdown; do != nil {
|
if do := u.Features().Shutdown; do != nil {
|
||||||
err := do(ctx)
|
err := do(ctx)
|
||||||
|
if err != nil {
|
||||||
errs[i] = fmt.Errorf("%s: %w", u.Name(), err)
|
errs[i] = fmt.Errorf("%s: %w", u.Name(), err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return errs.Err()
|
return errs.Err()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user