httpreader: Make linter happy
This commit is contained in:
parent
a7d29c9564
commit
24945a906a
@ -7,9 +7,13 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"go.uber.org/multierr"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
var log = logging.Logger("httpreader")
|
||||
|
||||
type ResumableReader struct {
|
||||
ctx context.Context
|
||||
initialURL string
|
||||
@ -57,7 +61,9 @@ func NewResumableReader(ctx context.Context, url string) (*ResumableReader, erro
|
||||
|
||||
contentLength, err := strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)
|
||||
if err != nil {
|
||||
resp.Body.Close()
|
||||
if err = resp.Body.Close(); err != nil {
|
||||
err = multierr.Append(err, err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -100,10 +106,14 @@ func (r *ResumableReader) Read(p []byte) (n int, err error) {
|
||||
|
||||
if err == io.EOF || err == io.ErrUnexpectedEOF {
|
||||
if r.position == r.contentLength {
|
||||
r.reader.Close()
|
||||
return n, err
|
||||
if err := r.reader.Close(); err != nil {
|
||||
log.Warnf("error closing reader: %+v", err)
|
||||
}
|
||||
return n, io.EOF
|
||||
}
|
||||
if err := r.reader.Close(); err != nil {
|
||||
log.Warnf("error closing reader: %+v", err)
|
||||
}
|
||||
r.reader.Close()
|
||||
r.reader = nil
|
||||
} else {
|
||||
return n, err
|
||||
|
Loading…
Reference in New Issue
Block a user