forked from TrueCloudLab/frostfs-node
25 lines
527 B
Go
25 lines
527 B
Go
package util
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
)
|
|
|
|
// MergeECInfo ignores conflicts and rewrites `to` with non empty values
|
|
// from `from`.
|
|
func MergeECInfo(from, to *objectSDK.ECInfo) *objectSDK.ECInfo {
|
|
for _, fchunk := range from.Chunks {
|
|
add := true
|
|
for _, tchunk := range to.Chunks {
|
|
if bytes.Equal(tchunk.ID.GetValue(), fchunk.ID.GetValue()) {
|
|
add = false
|
|
break
|
|
}
|
|
}
|
|
if add {
|
|
to.AddChunk(*objectSDK.NewECChunkFromV2(&fchunk))
|
|
}
|
|
}
|
|
return to
|
|
}
|