fix display size on repo page

This commit is contained in:
Evan Jarrett
2026-05-17 15:34:30 -05:00
parent f4acdd76eb
commit 6b4781941b
+10 -6
View File
@@ -24,7 +24,7 @@ import (
type SelectedTagData struct {
Info *db.TagWithPlatforms
LayerCount int
CompressedSize int64 // total across all platforms
CompressedSize int64 // largest platform's size for multi-arch; size for single-arch
ScanBatchParams []template.HTML
}
@@ -122,14 +122,18 @@ func (h *RepositoryPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
}
tagData.Platforms = platforms
// Compute total compressed size across all platforms
var totalSize int64
// For multi-arch, show the largest platform's size — a client only
// pulls one platform, so summing across all would overstate the
// download size.
var displaySize int64
if tagData.IsMultiArch {
for _, p := range platforms {
totalSize += p.CompressedSize
if p.CompressedSize > displaySize {
displaySize = p.CompressedSize
}
}
} else {
totalSize = tagData.CompressedSize
displaySize = tagData.CompressedSize
}
// Get layer count from image config (includes empty layers)
@@ -162,7 +166,7 @@ func (h *RepositoryPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
selectedTag = &SelectedTagData{
Info: tagData,
LayerCount: layerCount,
CompressedSize: totalSize,
CompressedSize: displaySize,
ScanBatchParams: scanBatchParams,
}
}