mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-12 16:49:03 +08:00
refactor
This commit is contained in:
parent
870a30665b
commit
3d8b8ffced
@ -199,6 +199,7 @@ func GitHubLatestRelease(ctx context.Context, ver string, owner, repo string) (R
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return Release{}, err
|
return Release{}, err
|
||||||
}
|
}
|
||||||
|
defer util.CloseResponse(res)
|
||||||
|
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
content := res.Header.Get("Content-Type")
|
content := res.Header.Get("Content-Type")
|
||||||
@ -211,17 +212,10 @@ func GitHubLatestRelease(ctx context.Context, ver string, owner, repo string) (R
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = res.Body.Close()
|
|
||||||
return Release{}, fmt.Errorf("unexpected status %v (%v) returned", res.StatusCode, res.Status)
|
return Release{}, fmt.Errorf("unexpected status %v (%v) returned", res.StatusCode, res.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(res.Body)
|
buf, err := ioutil.ReadAll(res.Body)
|
||||||
if err != nil {
|
|
||||||
_ = res.Body.Close()
|
|
||||||
return Release{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = res.Body.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Release{}, err
|
return Release{}, err
|
||||||
}
|
}
|
||||||
@ -265,18 +259,13 @@ func getGithubData(ctx context.Context, url string) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer util.CloseResponse(res)
|
||||||
|
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
return nil, fmt.Errorf("unexpected status %v (%v) returned", res.StatusCode, res.Status)
|
return nil, fmt.Errorf("unexpected status %v (%v) returned", res.StatusCode, res.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadAll(res.Body)
|
buf, err := ioutil.ReadAll(res.Body)
|
||||||
if err != nil {
|
|
||||||
_ = res.Body.Close()
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = res.Body.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,7 @@ func readChunkNeedle(fileUrl string, w io.Writer, offset int64, jwt string) (wri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return written, err
|
return written, err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer util.CloseResponse(resp)
|
||||||
io.Copy(io.Discard, resp.Body)
|
|
||||||
resp.Body.Close()
|
|
||||||
}()
|
|
||||||
|
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case http.StatusRequestedRangeNotSatisfiable:
|
case http.StatusRequestedRangeNotSatisfiable:
|
||||||
|
Loading…
Reference in New Issue
Block a user