mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-08 19:27:06 +00:00
fix display size on repo page
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user