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
Refs #3658

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
  • Loading branch information
AliceInHunterland committed Nov 2, 2024
1 parent c955c1e commit 06c9124
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cli/util/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ func uploadObj(ctx context.Context, p *pool.Pool, signer user.Signer, owner util
chHomomorphic checksum.Checksum
v = new(version.Version)
prmObjectPutInit client.PrmObjectPutInit
emptyOid = make([]byte, oidSize)
)

ownerID.SetScriptHash(owner)
Expand Down Expand Up @@ -581,11 +582,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 {
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(emptyOid)) {
return fmt.Errorf("object ID is empty")
}
return nil
}

Expand Down

0 comments on commit 06c9124

Please sign in to comment.