From 8d08e5b01208d72dfdab877e2bcee5676b3ec5da Mon Sep 17 00:00:00 2001 From: bufdev Date: Thu, 7 Nov 2024 13:11:50 -0500 Subject: [PATCH] commit --- .../bufpkg/bufmodule/bufmodulecache/base_provider.go | 11 +++++++++++ .../bufmodule/bufmodulecache/module_data_provider.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/private/bufpkg/bufmodule/bufmodulecache/base_provider.go b/private/bufpkg/bufmodule/bufmodulecache/base_provider.go index ef956edd19..eb2edaae25 100644 --- a/private/bufpkg/bufmodule/bufmodulecache/base_provider.go +++ b/private/bufpkg/bufmodule/bufmodulecache/base_provider.go @@ -80,6 +80,17 @@ func (p *baseProvider[K, V]) getValuesForKeys(ctx context.Context, keys []K) ([] ); err != nil { return nil, err } + // We are getting the values again so that we retrieve the values from the cache directly. + // This matters for ie ModuleDatas where the storage.Bucket attached will have local paths + // instead of empty local paths if read from the cache. We documment NewModuleDataProvider + // to return a ModuleDataProvider that will always have local paths for returned storage.Buckets. + delegateValues, err = p.delegateGetValuesForKeys( + ctx, + notFoundKeys, + ) + if err != nil { + return nil, err + } p.keysRetrieved.Add(int64(len(keys))) p.keysHit.Add(int64(len(foundValues))) diff --git a/private/bufpkg/bufmodule/bufmodulecache/module_data_provider.go b/private/bufpkg/bufmodule/bufmodulecache/module_data_provider.go index 1cbd006568..4bf1dc70f2 100644 --- a/private/bufpkg/bufmodule/bufmodulecache/module_data_provider.go +++ b/private/bufpkg/bufmodule/bufmodulecache/module_data_provider.go @@ -26,6 +26,8 @@ import ( // NewModuleDataProvider returns a new ModuleDataProvider that caches the results of the delegate. // // The ModuleDataStore is used as a cache. +// +// All files in returned [storage.Bucket]s will have local paths. func NewModuleDataProvider( logger *slog.Logger, delegate bufmodule.ModuleDataProvider,