forked from TrueCloudLab/frostfs-node
[#477] engine: Reuse SplitInfoError fix for engine.Get
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7547592ce3
commit
7e435db292
1 changed files with 22 additions and 3 deletions
|
@ -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"
|
||||||
)
|
)
|
||||||
|
@ -50,6 +51,7 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
|
||||||
obj *object.Object
|
obj *object.Object
|
||||||
siErr *objectSDK.SplitInfoError
|
siErr *objectSDK.SplitInfoError
|
||||||
|
|
||||||
|
outSI *objectSDK.SplitInfo
|
||||||
outError = object.ErrNotFound
|
outError = object.ErrNotFound
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,9 +64,22 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, 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
|
case errors.As(err, &siErr):
|
||||||
errors.Is(err, object.ErrAlreadyRemoved),
|
siErr = err.(*objectSDK.SplitInfoError)
|
||||||
errors.As(err, &siErr):
|
|
||||||
|
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):
|
||||||
outError = err
|
outError = err
|
||||||
|
|
||||||
return true // stop, return it back
|
return true // stop, return it back
|
||||||
|
@ -85,6 +100,10 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, 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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue