MCPcopy Create free account
hub / github.com/bufbuild/buf / getFileInfo

Method getFileInfo

private/bufpkg/bufmodule/module_read_bucket.go:462–472  ·  view source on GitHub ↗
(ctx context.Context, objectInfo storage.ObjectInfo)

Source from the content-addressed store, hash-verified

460func (*moduleReadBucket) isModuleReadBucket() {}
461
462func (b *moduleReadBucket) getFileInfo(ctx context.Context, objectInfo storage.ObjectInfo) (FileInfo, error) {
463 return b.pathToFileInfoCache.GetOrAdd(
464 // We know that storage.ObjectInfo will always have the same values for the same
465 // ObjectInfo returned from a common bucket, this is documented. Therefore, we
466 // can cache based on just the path.
467 objectInfo.Path(),
468 func() (FileInfo, error) {
469 return b.getFileInfoUncached(ctx, objectInfo)
470 },
471 )
472}
473
474func (b *moduleReadBucket) getFileInfoUncached(ctx context.Context, objectInfo storage.ObjectInfo) (FileInfo, error) {
475 fileType, err := FileTypeForPath(objectInfo.Path())

Callers 2

StatFileInfoMethod · 0.95
WalkFileInfosMethod · 0.95

Calls 3

getFileInfoUncachedMethod · 0.95
GetOrAddMethod · 0.80
PathMethod · 0.65

Tested by

no test coverage detected