From 148ad143d5fa7798cdb24002d1363185874380a2 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Sat, 2 Nov 2024 21:43:20 +0300 Subject: [PATCH] cli: fix missing errors on closure of writer in `upload-bin` Ref #3658 Signed-off-by: Ekaterina Pavlova --- cli/util/uploader.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/util/uploader.go b/cli/util/uploader.go index 612f0a9304..f8ede06001 100644 --- a/cli/util/uploader.go +++ b/cli/util/uploader.go @@ -581,11 +581,19 @@ func uploadObj(ctx context.Context, p *pool.Pool, signer user.Signer, owner util if err != nil { return fmt.Errorf("failed to initiate object upload: %w", err) } - defer writer.Close() _, err = writer.Write(objData) if err != nil { + _ = writer.Close() return fmt.Errorf("failed to write object data: %w", err) } + err = writer.Close() + if err != nil { + return fmt.Errorf("failed to close object writer: %w", err) + } + res := writer.GetResult() + if res.StoredObjectID().Equals(oid.ID{}) { + return fmt.Errorf("object ID is empty") + } return nil }