From 7e435db2927b6269bf9ba7e0c662723ed316896f Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 14 Apr 2021 12:05:20 +0300 Subject: [PATCH] [#477] engine: Reuse SplitInfoError fix for `engine.Get` Signed-off-by: Alex Vanin --- pkg/local_object_storage/engine/get.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pkg/local_object_storage/engine/get.go b/pkg/local_object_storage/engine/get.go index 05e4a2623..bc79d76c9 100644 --- a/pkg/local_object_storage/engine/get.go +++ b/pkg/local_object_storage/engine/get.go @@ -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" ) @@ -50,6 +51,7 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { obj *object.Object siErr *objectSDK.SplitInfoError + outSI *objectSDK.SplitInfo outError = object.ErrNotFound ) @@ -62,9 +64,22 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { switch { case errors.Is(err, object.ErrNotFound): return false // ignore, go to next shard - case - errors.Is(err, object.ErrAlreadyRemoved), - errors.As(err, &siErr): + 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): outError = err return true // stop, return it back @@ -85,6 +100,10 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) { return true }) + if outSI != nil { + return nil, objectSDK.NewSplitInfoError(outSI) + } + if obj == nil { return nil, outError }