1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 07:43:03 +00:00

Merge pull request #3251 from MichaelEischer/rest-dropped-error

rest: handle dropped error in save operation
This commit is contained in:
Alexander Neumann 2021-01-30 19:44:50 +01:00 committed by GitHub
commit 6ab7d49a03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
b.sem.ReleaseToken()
var cerr error
if resp != nil {
defer func() {
_, _ = io.Copy(ioutil.Discard, resp.Body)
e := resp.Body.Close()
if err == nil {
err = errors.Wrap(e, "Close")
}
}()
_, _ = io.Copy(ioutil.Discard, resp.Body)
cerr = resp.Body.Close()
}
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 nil
return errors.Wrap(cerr, "Close")
}
// ErrIsNotExist is returned whenever the requested file does not exist on the