MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / statCache

Method statCache

cmd/disk-cache-backend.go:566–587  ·  view source on GitHub ↗

statCache is a convenience function for purge() to get ObjectInfo for cached object

(ctx context.Context, cacheObjPath string)

Source from the content-addressed store, hash-verified

564
565// statCache is a convenience function for purge() to get ObjectInfo for cached object
566func (c *diskCache) statCache(ctx context.Context, cacheObjPath string) (meta *cacheMeta, partial bool, numHits int, err error) {
567 // Stat the file to get file size.
568 metaPath := pathJoin(cacheObjPath, cacheMetaJSONFile)
569 f, err := os.Open(metaPath)
570 if err != nil {
571 return meta, partial, 0, err
572 }
573 defer f.Close()
574 meta = &cacheMeta{Version: cacheMetaVersion}
575 if err := jsonLoad(f, meta); err != nil {
576 return meta, partial, 0, err
577 }
578 // get metadata of part.1 if full file has been cached.
579 partial = true
580 if _, err := os.Stat(pathJoin(cacheObjPath, cacheDataFile)); err == nil {
581 partial = false
582 }
583 if writebackInProgress(meta.Meta) {
584 partial = false
585 }
586 return meta, partial, meta.Hits, nil
587}
588
589// saves object metadata to disk cache
590// incHitsOnly is true if metadata update is incrementing only the hit counter

Callers 4

statCachedMetaMethod · 0.95
putMethod · 0.95
PutObjectPartMethod · 0.95

Calls 6

pathJoinFunction · 0.85
jsonLoadFunction · 0.85
writebackInProgressFunction · 0.85
CloseMethod · 0.65
StatMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected