From 70c667492ada3e48fe23525b6a7c5d82282807a5 Mon Sep 17 00:00:00 2001 From: ajayk Date: Sun, 5 Jan 2025 19:14:42 -0800 Subject: [PATCH] minor go cleanup --- pkg/http/http.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/http/http.go b/pkg/http/http.go index 7de77a44d..99e04fb8d 100644 --- a/pkg/http/http.go +++ b/pkg/http/http.go @@ -61,17 +61,12 @@ func (c *RLHTTPClient) GetArtifactSHA256(ctx context.Context, artifactURI string } defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { return "", fmt.Errorf("%d when getting %s", resp.StatusCode, artifactURI) } - - body, err := io.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("reading body: %w", err) - } - h256 := sha256.New() - h256.Write(body) + if _, err := io.Copy(h256, resp.Body); err != nil { + return "", fmt.Errorf("hashing %s: %w", artifactURI, err) + } return fmt.Sprintf("%x", h256.Sum(nil)), nil }