forked from TrueCloudLab/frostfs-node
[#40] object/put: Assign zero return of MaxObjectSize invalid
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
43533c991e
commit
968033deed
2 changed files with 10 additions and 1 deletions
|
@ -13,6 +13,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type MaxSizeSource interface {
|
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
|
MaxObjectSize() uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,13 @@ func (p *Streamer) initTarget(prm *PutInitPrm) error {
|
||||||
return errors.Wrapf(err, "(%T) could not receive session key", p)
|
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.target = transformer.NewPayloadSizeLimiter(
|
||||||
p.maxSizeSrc.MaxObjectSize(),
|
maxSz,
|
||||||
func() transformer.ObjectTarget {
|
func() transformer.ObjectTarget {
|
||||||
return transformer.NewFormatTarget(&transformer.FormatterParams{
|
return transformer.NewFormatTarget(&transformer.FormatterParams{
|
||||||
Key: sessionKey,
|
Key: sessionKey,
|
||||||
|
|
Loading…
Reference in a new issue