Skip to content

Commit

Permalink
cli: fix missing errors on closure of writer in upload-bin
Browse files Browse the repository at this point in the history
Ref #3658

Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed Nov 5, 2024
1 parent 95098d4 commit 148ad14
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/util/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 148ad14

Please sign in to comment.