From 73494c4bbc3f9cd4b65968b1b42d0901b7be810b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 18 Nov 2020 10:59:47 +0300 Subject: [PATCH] [#176] localstore: Fix Get with non-zero length GetPrm has WithPayloadRange option to specify the requested payload range. In previous implementation StorageEngine.Get method ignored this option. From now zero length matches full payload request. Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/engine/get.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/local_object_storage/engine/get.go b/pkg/local_object_storage/engine/get.go index a3b8501a3..b3e5d41d6 100644 --- a/pkg/local_object_storage/engine/get.go +++ b/pkg/local_object_storage/engine/get.go @@ -37,7 +37,7 @@ func (p *GetPrm) WithAddress(addr *objectSDK.Address) *GetPrm { // WithPayloadRange is a Get option to set range of requested payload data. // -// Missing an option or calling with zero arguments is equivalent +// Missing an option or calling with zero length is equivalent // to getting the full payload range. func (p *GetPrm) WithPayloadRange(off, ln uint64) *GetPrm { if p != nil { @@ -67,8 +67,13 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { var obj *object.Object shPrm := new(shard.GetPrm). - WithAddress(prm.addr). - WithFullRange() + WithAddress(prm.addr) + + if prm.ln == 0 { + shPrm = shPrm.WithFullRange() + } else { + shPrm = shPrm.WithRange(prm.off, int64(prm.ln)) + } e.iterateOverSortedShards(prm.addr, func(sh *shard.Shard) (stop bool) { res, err := sh.Get(shPrm)