cli: extend object attribute parsing error in upload-bin

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-10-23 13:14:35 +03:00
parent 5b793bcf1b
commit 8b43c33e44

View file

@ -483,7 +483,12 @@ func uploadObj(ctx context.Context, p *pool.Pool, signer user.Signer, owner util
func getBlockIndex(header *object.Object, attribute string) (int, error) {
for _, attr := range header.UserAttributes() {
if attr.Key() == attribute {
return strconv.Atoi(attr.Value())
value := attr.Value()
blockIndex, err := strconv.Atoi(value)
if err != nil {
return -1, fmt.Errorf("attribute %s has invalid value: %s, error: %w", attribute, value, err)
}
return blockIndex, nil
}
}
return -1, fmt.Errorf("attribute %s not found", attribute)