statCache is a convenience function for purge() to get ObjectInfo for cached object
(ctx context.Context, cacheObjPath string)
| 564 | |
| 565 | // statCache is a convenience function for purge() to get ObjectInfo for cached object |
| 566 | func (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 |
no test coverage detected