fix(updatecheck): ensure response body is closed properly
This commit is contained in:
@@ -131,7 +131,7 @@ func downloadAndRunInstaller(ctx context.Context, url string, out io.Writer) err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("downloading installer: %w", err)
|
return fmt.Errorf("downloading installer: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return fmt.Errorf("downloading installer: unexpected status %s", resp.Status)
|
return fmt.Errorf("downloading installer: unexpected status %s", resp.Status)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func Latest(ctx context.Context, client *http.Client, apiURL string) (*Release,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("checking for updates: %w", err)
|
return nil, fmt.Errorf("checking for updates: %w", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return nil, fmt.Errorf("checking for updates: unexpected status %s", resp.Status)
|
return nil, fmt.Errorf("checking for updates: unexpected status %s", resp.Status)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user