Use all available metadata including {size, version, ETag, MD5, CRC} to compare local object with its remote counterpart.
(lom *cluster.LOM, dst *DstElement)
| 235 | // Use all available metadata including {size, version, ETag, MD5, CRC} |
| 236 | // to compare local object with its remote counterpart. |
| 237 | func 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 | } |