From 870112717355b0f77ce99dc2b11935319eb70335 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Thu, 2 May 2024 08:46:02 +0700 Subject: [PATCH] fix redundant err check --- store/snapshots/store.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/store/snapshots/store.go b/store/snapshots/store.go index ec1d70c700f..f5dd345cb4b 100644 --- a/store/snapshots/store.go +++ b/store/snapshots/store.go @@ -153,13 +153,12 @@ func (s *Store) Load(height uint64, format uint32) (*types.Snapshot, <-chan io.R } err = func() error { defer chunk.Close() + if _, err := io.Copy(pw, chunk); err != nil { - return fmt.Errorf("failed to copy chunk %d: %w", i, err) - } - if err != nil { _ = pw.CloseWithError(err) - return err + return fmt.Errorf("failed to copy chunk %d: %w", i, err) } + return pw.Close() }() if err != nil {