From 847b5898220479e7cef17e29274125255dc75f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 17 Feb 2024 14:51:02 +0100 Subject: [PATCH] treed: Close out file --- provider/lpproof/treed_build.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/provider/lpproof/treed_build.go b/provider/lpproof/treed_build.go index bf91da8c8..e144f695b 100644 --- a/provider/lpproof/treed_build.go +++ b/provider/lpproof/treed_build.go @@ -51,11 +51,17 @@ func hashChunk(data [][]byte) { } } -func BuildTreeD(data io.Reader, unpaddedData bool, outPath string, size abi.PaddedPieceSize) (cid.Cid, error) { +func BuildTreeD(data io.Reader, unpaddedData bool, outPath string, size abi.PaddedPieceSize) (_ cid.Cid, err error) { out, err := os.Create(outPath) if err != nil { return cid.Undef, err } + defer func() { + cerr := out.Close() + if cerr != nil { + err = multierror.Append(err, cerr) + } + }() outSize := treeSize(size)