2021-04-15 07:23:52 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
import (
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
2021-04-15 07:23:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MergeSplitInfo ignores conflicts and rewrites `to` with non empty values
|
|
|
|
// from `from`.
|
2022-03-03 14:19:05 +00:00
|
|
|
func MergeSplitInfo(from, to *object.SplitInfo) *object.SplitInfo {
|
2021-04-15 07:23:52 +00:00
|
|
|
to.SetSplitID(from.SplitID()) // overwrite SplitID and ignore conflicts
|
|
|
|
|
2022-05-12 16:37:46 +00:00
|
|
|
if lp, ok := from.LastPart(); ok {
|
2021-04-15 07:23:52 +00:00
|
|
|
to.SetLastPart(lp)
|
|
|
|
}
|
|
|
|
|
2022-05-12 16:37:46 +00:00
|
|
|
if link, ok := from.Link(); ok {
|
2021-04-15 07:23:52 +00:00
|
|
|
to.SetLink(link)
|
|
|
|
}
|
|
|
|
|
|
|
|
return to
|
|
|
|
}
|