MCPcopy
hub / github.com/NVIDIA/aistore / CompareObjects

Function CompareObjects

downloader/utils.go:237–256  ·  view source on GitHub ↗

Use all available metadata including {size, version, ETag, MD5, CRC} to compare local object with its remote counterpart.

(lom *cluster.LOM, dst *DstElement)

Source from the content-addressed store, hash-verified

235// Use all available metadata including {size, version, ETag, MD5, CRC}
236// to compare local object with its remote counterpart.
237func CompareObjects(lom *cluster.LOM, dst *DstElement) (equal bool, err error) {
238 var oa *cmn.ObjAttrs
239 if dst.Link != "" {
240 resp, errHead := headLink(dst.Link)
241 if errHead != nil {
242 return false, errHead
243 }
244 oa = &cmn.ObjAttrs{}
245 oa.Size = attrsFromLink(dst.Link, resp, oa)
246 } else {
247 ctx, cancel := context.WithTimeout(context.Background(), headReqTimeout)
248 defer cancel()
249 oa, _, err = cluster.T.Backend(lom.Bck()).HeadObj(ctx, lom)
250 if err != nil {
251 return false, err
252 }
253 }
254 equal = lom.Equal(oa)
255 return
256}

Callers 2

TestCompareObjectFunction · 0.92
CompareObjectsMethod · 0.85

Calls 6

headLinkFunction · 0.85
attrsFromLinkFunction · 0.85
HeadObjMethod · 0.65
BackendMethod · 0.65
BckMethod · 0.65
EqualMethod · 0.45

Tested by 1

TestCompareObjectFunction · 0.74