Skip to content

Commit 5328172

Browse files
committed
Fix the cache broken by the ociref changes
One part of the code was storing keys in our `sync.Map` as a `string` and the other as a `Reference` so they never matched. 😭 If `sync.Map` had been written in the brave new world of Go generics, we'd have a compilation error to help us catch this. 🤦 We *could* get clever with something like a `--network=none` container that forces `builds` to use the cache, but it's a bit complex to set up correctly (so instead I think we should wait for the eventual `sync/v2` upstream Go package or fork/write/switch to a separate "generic" / type-safe `sync.Map` package in the future).
1 parent 1456103 commit 5328172

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/builds/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func loadCacheFromFile() error {
171171

172172
for img, index := range cache.Indexes {
173173
index := index // https://github.com/golang/go/issues/60078
174-
fun, _ := cacheResolve.LoadOrStore(img, sync.OnceValues(func() (*ocispec.Index, error) {
174+
fun, _ := cacheResolve.LoadOrStore(img.String(), sync.OnceValues(func() (*ocispec.Index, error) {
175175
return index, nil
176176
}))
177177
index2, err := fun.(func() (*ocispec.Index, error))()

0 commit comments

Comments
 (0)