forked from TrueCloudLab/frostfs-node
[#477] engine: Reuse SplitInfoError fix for engine.Range
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7e435db292
commit
bc09e29bfd
1 changed files with 22 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/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"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -68,6 +69,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
|
|||
obj *object.Object
|
||||
siErr *objectSDK.SplitInfoError
|
||||
|
||||
outSI *objectSDK.SplitInfo
|
||||
outError = object.ErrNotFound
|
||||
)
|
||||
|
||||
|
@ -81,10 +83,24 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
|
|||
switch {
|
||||
case errors.Is(err, object.ErrNotFound):
|
||||
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
|
||||
errors.Is(err, object.ErrAlreadyRemoved),
|
||||
errors.Is(err, object.ErrRangeOutOfBounds),
|
||||
errors.As(err, &siErr):
|
||||
errors.Is(err, object.ErrRangeOutOfBounds):
|
||||
outError = err
|
||||
|
||||
return true // stop, return it back
|
||||
|
@ -105,6 +121,10 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
|
|||
return true
|
||||
})
|
||||
|
||||
if outSI != nil {
|
||||
return nil, objectSDK.NewSplitInfoError(outSI)
|
||||
}
|
||||
|
||||
if obj == nil {
|
||||
return nil, outError
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue