diff options
| author | chrislu <chris.lu@gmail.com> | 2022-08-31 00:24:29 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-08-31 00:24:29 -0700 |
| commit | 3d8b8ffcedaa0b3aa1306153c8e30e5e8525b7ac (patch) | |
| tree | a0276eaadf498589ff3de88d2ed8f37621b0e400 /weed/command/update.go | |
| parent | 870a30665b69da95bba304e8d2c4b7affa29896f (diff) | |
| download | seaweedfs-3d8b8ffcedaa0b3aa1306153c8e30e5e8525b7ac.tar.xz seaweedfs-3d8b8ffcedaa0b3aa1306153c8e30e5e8525b7ac.zip | |
refactor
Diffstat (limited to 'weed/command/update.go')
| -rw-r--r-- | weed/command/update.go | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/weed/command/update.go b/weed/command/update.go index 89efae79a..30b15cc99 100644 --- a/weed/command/update.go +++ b/weed/command/update.go @@ -199,6 +199,7 @@ func GitHubLatestRelease(ctx context.Context, ver string, owner, repo string) (R if err != nil { return Release{}, err } + defer util.CloseResponse(res) if res.StatusCode != http.StatusOK { content := res.Header.Get("Content-Type") @@ -211,18 +212,11 @@ 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) } buf, err := ioutil.ReadAll(res.Body) if err != nil { - _ = res.Body.Close() - return Release{}, err - } - - err = res.Body.Close() - if err != nil { return Release{}, err } @@ -265,6 +259,7 @@ func getGithubData(ctx context.Context, url string) ([]byte, error) { if err != nil { return nil, err } + defer util.CloseResponse(res) if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("unexpected status %v (%v) returned", res.StatusCode, res.Status) @@ -272,12 +267,6 @@ func getGithubData(ctx context.Context, url string) ([]byte, error) { buf, err := ioutil.ReadAll(res.Body) if err != nil { - _ = res.Body.Close() - return nil, err - } - - err = res.Body.Close() - if err != nil { return nil, err } |
