[#477] metabase: Move MergeSplitInfo to storage/util pkg

This function already reused in different storage engine parts
so it makes sense to keep it in separate package.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-15 10:23:52 +03:00 committed by Alex Vanin
parent bc09e29bfd
commit 9a961e21b1
6 changed files with 95 additions and 23 deletions

View file

@ -9,6 +9,7 @@ import (
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/local_object_storage/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util"
"go.etcd.io/bbolt"
)
@ -416,7 +417,7 @@ func updateSplitInfo(tx *bbolt.Tx, addr *objectSDK.Address, from *objectSDK.Spli
return fmt.Errorf("can't unmarshal split info from root index: %w", err)
}
result := MergeSplitInfo(from, to)
result := util.MergeSplitInfo(from, to)
rawSplitInfo, err = result.Marshal()
if err != nil {
@ -448,22 +449,6 @@ func splitInfoFromObject(obj *object.Object) (*objectSDK.SplitInfo, error) {
return info, nil
}
// MergeSplitInfo ignores conflicts and rewrites `to` with non empty values
// from `from`.
func MergeSplitInfo(from, to *objectSDK.SplitInfo) *objectSDK.SplitInfo {
to.SetSplitID(from.SplitID()) // overwrite SplitID and ignore conflicts
if lp := from.LastPart(); lp != nil {
to.SetLastPart(lp)
}
if link := from.Link(); link != nil {
to.SetLink(link)
}
return to
}
// isLinkObject returns true if object contains parent header and list
// of children.
func isLinkObject(obj *object.Object) bool {