mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
rest: handle dropped error in save operation
This commit is contained in:
parent
dd94efb307
commit
a53778cd83
1 changed files with 4 additions and 9 deletions
|
@ -132,15 +132,10 @@ func (b *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRea
|
||||||
resp, err := ctxhttp.Do(ctx, b.client, req)
|
resp, err := ctxhttp.Do(ctx, b.client, req)
|
||||||
b.sem.ReleaseToken()
|
b.sem.ReleaseToken()
|
||||||
|
|
||||||
|
var cerr error
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
defer func() {
|
|
||||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||||
e := resp.Body.Close()
|
cerr = resp.Body.Close()
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
err = errors.Wrap(e, "Close")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -151,7 +146,7 @@ func (b *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRea
|
||||||
return errors.Errorf("server response unexpected: %v (%v)", resp.Status, resp.StatusCode)
|
return errors.Errorf("server response unexpected: %v (%v)", resp.Status, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return errors.Wrap(cerr, "Close")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrIsNotExist is returned whenever the requested file does not exist on the
|
// ErrIsNotExist is returned whenever the requested file does not exist on the
|
||||||
|
|
Loading…
Reference in a new issue