[#477] engine: Reuse SplitInfoError fix for engine.Range

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-14 12:05:53 +03:00 committed by Alex Vanin
parent 7e435db292
commit bc09e29bfd

View file

@ -5,6 +5,7 @@ import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object" objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -68,6 +69,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
obj *object.Object obj *object.Object
siErr *objectSDK.SplitInfoError siErr *objectSDK.SplitInfoError
outSI *objectSDK.SplitInfo
outError = object.ErrNotFound outError = object.ErrNotFound
) )
@ -81,10 +83,24 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
switch { switch {
case errors.Is(err, object.ErrNotFound): case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard return false // ignore, go to next shard
case errors.As(err, &siErr):
siErr = err.(*objectSDK.SplitInfoError)
if outSI == nil {
outSI = objectSDK.NewSplitInfo()
}
meta.MergeSplitInfo(siErr.SplitInfo(), outSI)
// stop iterating over shards if SplitInfo structure is complete
if outSI.Link() != nil && outSI.LastPart() != nil {
return true
}
return false
case case
errors.Is(err, object.ErrAlreadyRemoved), errors.Is(err, object.ErrAlreadyRemoved),
errors.Is(err, object.ErrRangeOutOfBounds), errors.Is(err, object.ErrRangeOutOfBounds):
errors.As(err, &siErr):
outError = err outError = err
return true // stop, return it back return true // stop, return it back
@ -105,6 +121,10 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
return true return true
}) })
if outSI != nil {
return nil, objectSDK.NewSplitInfoError(outSI)
}
if obj == nil { if obj == nil {
return nil, outError return nil, outError
} }