Skip to content

Commit

Permalink
Fix first cache manifets
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jan 17, 2025
1 parent e28ec2f commit 997fbce
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cache/cache_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,23 @@ func (c *Cache) PutManifestContent(ctx context.Context, host, image, tagOrBlob s

h := sha256.New()
h.Write(content)
hash := hex.EncodeToString(h.Sum(nil)[:])
hash := "sha256:" + hex.EncodeToString(h.Sum(nil)[:])

isHash := strings.HasPrefix(tagOrBlob, "sha256:")
if isHash {
tagOrBlob = tagOrBlob[7:]
if tagOrBlob != hash {
return 0, "", "", fmt.Errorf("expected hash %s is not same to %s", tagOrBlob, hash)
}
} else {
manifestLinkPath := manifestTagCachePath(host, image, tagOrBlob)
err := c.PutContent(ctx, manifestLinkPath, []byte("sha256:"+hash))
err := c.PutContent(ctx, manifestLinkPath, []byte(hash))
if err != nil {
return 0, "", "", fmt.Errorf("put manifest link path %s error: %w", manifestLinkPath, err)
}
}

manifestLinkPath := manifestRevisionsCachePath(host, image, hash)
err = c.PutContent(ctx, manifestLinkPath, []byte("sha256:"+hash))
err = c.PutContent(ctx, manifestLinkPath, []byte(hash))
if err != nil {
return 0, "", "", fmt.Errorf("put manifest revisions path %s error: %w", manifestLinkPath, err)
}
Expand Down

0 comments on commit 997fbce

Please sign in to comment.