diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a937b895da..b5dd293e45 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -286,8 +286,8 @@ func ImportHistory(chain *core.BlockChain, dir string, network string, from func if err != nil { return fmt.Errorf("open %s: %w", path, err) } + defer f.Close() if _, err := io.Copy(h, f); err != nil { - f.Close() return fmt.Errorf("checksum %s: %w", path, err) } got := common.BytesToHash(h.Sum(scratch.Bytes()[:])).Hex() @@ -296,7 +296,6 @@ func ImportHistory(chain *core.BlockChain, dir string, network string, from func scratch.Reset() if got != want { - f.Close() return fmt.Errorf("%s checksum mismatch: have %s want %s", file, got, want) } // Import all block data from Era1.