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

Function Load

cmn/jsp/file.go:77–97  ·  view source on GitHub ↗
(filepath string, v interface{}, opts Options)

Source from the content-addressed store, hash-verified

75}
76
77func Load(filepath string, v interface{}, opts Options) (checksum *cos.Cksum, err error) {
78 var file *os.File
79 file, err = os.Open(filepath)
80 if err != nil {
81 return
82 }
83 checksum, err = Decode(file, v, opts, filepath)
84 if err == nil {
85 return
86 }
87 if errors.Is(err, &cos.ErrBadCksum{}) {
88 if errRm := os.Remove(filepath); errRm == nil {
89 if flag.Parsed() {
90 glog.Errorf("bad checksum: removing %s", filepath)
91 }
92 } else if flag.Parsed() {
93 glog.Errorf("bad checksum: failed to remove %s: %v", filepath, errRm)
94 }
95 }
96 return
97}

Callers 9

LoadConfigFunction · 0.92
formatMetaFunction · 0.92
formatECMetaFunction · 0.92
emd_test.goFile · 0.92
bucketmeta_test.goFile · 0.92
runPreMethod · 0.92
_configMethod · 0.92
LoadMetaFunction · 0.70
LoadAppConfigFunction · 0.70

Calls 5

ErrorfFunction · 0.92
DecodeFunction · 0.85
IsMethod · 0.80
OpenMethod · 0.65
RemoveMethod · 0.45

Tested by

no test coverage detected