From 0634dfce07cbd3046e1c6737ab87448a52de0c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 22 Feb 2024 11:39:17 +0100 Subject: [PATCH] Fix lint --- provider/lpproof/treed_build_test.go | 4 +++- storage/paths/remote.go | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/provider/lpproof/treed_build_test.go b/provider/lpproof/treed_build_test.go index c97184fb2..f9bbde20a 100644 --- a/provider/lpproof/treed_build_test.go +++ b/provider/lpproof/treed_build_test.go @@ -315,7 +315,9 @@ func Test32G(t *testing.T) { // dump tree.dat datFile, err := os.Open(tempFile) require.NoError(t, err) - defer datFile.Close() + defer func() { + require.NoError(t, datFile.Close()) + }() actualD := hexPrint32LDedup(bufio.NewReaderSize(datFile, 1<<20)) fmt.Println(actualD) diff --git a/storage/paths/remote.go b/storage/paths/remote.go index afa589683..882c98c4a 100644 --- a/storage/paths/remote.go +++ b/storage/paths/remote.go @@ -430,12 +430,13 @@ func (r *Remote) FsStat(ctx context.Context, id storiface.ID) (fsutil.FsStat, er } _ = resp.Body.Close() return out, nil // Successfully decoded, return the result - } else { - b, _ := io.ReadAll(resp.Body) // Best-effort read the body for logging - log.Warnw("request to endpoint failed", "url", rl.String(), "statusCode", resp.StatusCode, "response", string(b)) - _ = resp.Body.Close() - // Continue to try the next URL, don't return here as we want to try all URLs } + + // non-200 status code + b, _ := io.ReadAll(resp.Body) // Best-effort read the body for logging + log.Warnw("request to endpoint failed", "url", rl.String(), "statusCode", resp.StatusCode, "response", string(b)) + _ = resp.Body.Close() + // Continue to try the next URL, don't return here as we want to try all URLs } return fsutil.FsStat{}, xerrors.Errorf("all endpoints failed for remote storage %s", id)