onedrive: Fix socket leak in multipart session upload

This had gone unnoticed until recently when we changed to uploading
all files with a multipart session.
This commit is contained in:
Nick Craig-Wood 2018-03-26 17:17:56 +01:00
parent 4d553ef701
commit 9df266a6b4

View file

@ -1125,12 +1125,14 @@ func (o *Object) uploadFragment(url string, start int64, totalSize int64, chunk
err = o.fs.pacer.Call(func() (bool, error) { err = o.fs.pacer.Call(func() (bool, error) {
_, _ = chunk.Seek(0, 0) _, _ = chunk.Seek(0, 0)
resp, err = o.fs.srv.Call(&opts) resp, err = o.fs.srv.Call(&opts)
if resp != nil {
defer fs.CheckClose(resp.Body, &err)
}
retry, err := shouldRetry(resp, err) retry, err := shouldRetry(resp, err)
if !retry && resp != nil { if !retry && resp != nil {
if resp.StatusCode == 200 || resp.StatusCode == 201 { if resp.StatusCode == 200 || resp.StatusCode == 201 {
// we are done :) // we are done :)
// read the item // read the item
defer fs.CheckClose(resp.Body, &err)
info = &api.Item{} info = &api.Item{}
return false, json.NewDecoder(resp.Body).Decode(info) return false, json.NewDecoder(resp.Body).Decode(info)
} }