From 9ca2faef6e4bbc88bfbaaccca846ee420b142e17 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Wed, 7 Aug 2024 08:33:16 +1000 Subject: [PATCH] fix(metadata): file closed too early (#273) This fixes an issue where the metadata provider closed a file that may still be in use. Fixes #264 --- metadata/decode.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/metadata/decode.go b/metadata/decode.go index f3c3de7f..24291f2e 100644 --- a/metadata/decode.go +++ b/metadata/decode.go @@ -80,10 +80,8 @@ func (d *Decoder) Parse(payload *PayloadJSON) (metadata *Metadata, err error) { return metadata, nil } -// Decode the blob from an io.ReadCloser. This function will close the io.ReadCloser after completing. -func (d *Decoder) Decode(r io.ReadCloser) (payload *PayloadJSON, err error) { - defer r.Close() - +// Decode the blob from an io.Reader. This function will close the io.ReadCloser after completing. +func (d *Decoder) Decode(r io.Reader) (payload *PayloadJSON, err error) { bytes, err := io.ReadAll(r) if err != nil { return nil, err