[#40] object/put: Assign zero return of MaxObjectSize invalid

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2020-10-22 17:20:59 +03:00 committed by Alex Vanin
parent 43533c991e
commit 968033deed
2 changed files with 10 additions and 1 deletions

View File

@ -13,6 +13,10 @@ import (
)
type MaxSizeSource interface {
// MaxObjectSize returns maximum payload size
// of physically stored object in system.
//
// Must return 0 if value can not be obtained.
MaxObjectSize() uint64
}

View File

@ -66,8 +66,13 @@ func (p *Streamer) initTarget(prm *PutInitPrm) error {
return errors.Wrapf(err, "(%T) could not receive session key", p)
}
maxSz := p.maxSizeSrc.MaxObjectSize()
if maxSz == 0 {
return errors.Errorf("(%T) could not obtain max object size parameter", p)
}
p.target = transformer.NewPayloadSizeLimiter(
p.maxSizeSrc.MaxObjectSize(),
maxSz,
func() transformer.ObjectTarget {
return transformer.NewFormatTarget(&transformer.FormatterParams{
Key: sessionKey,