From 968033deed88852565fcb14b184f4bcf31fcf768 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 22 Oct 2020 17:20:59 +0300 Subject: [PATCH] [#40] object/put: Assign zero return of MaxObjectSize invalid Signed-off-by: Leonard Lyubich --- pkg/services/object/put/service.go | 4 ++++ pkg/services/object/put/streamer.go | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/services/object/put/service.go b/pkg/services/object/put/service.go index bc8b6945..0659bac5 100644 --- a/pkg/services/object/put/service.go +++ b/pkg/services/object/put/service.go @@ -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 } diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index 7b798642..d7558d45 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -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,