[#58] object/put: Validate payload content after filling

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
support/v0.27
Leonard Lyubich 2020-09-30 20:54:25 +03:00 committed by Alex Vanin
parent 2abb03dbd1
commit 6eb353c804
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,8 @@ type distributedTarget struct {
chunks [][]byte
nodeTargetInitializer func(*network.Address) transformer.ObjectTarget
fmt *object.FormatValidator
}
var errIncompletePut = errors.New("incomplete object put")
@ -57,6 +59,10 @@ func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
payload = append(payload, t.chunks[i]...)
}
if err := t.fmt.ValidateContent(t.obj.GetType(), payload); err != nil {
return nil, errors.Wrapf(err, "(%T) could not validate payload content", t)
}
t.obj.SetPayload(payload)
loop: