cli: fix missing errors on closure of writer in upload-bin

Ref #3658

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-11-02 21:43:20 +03:00
parent 1a540d5883
commit 18ed3bb3e8

View file

@ -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
}