Skip to content

Commit

Permalink
api: packages: fix stats
Browse files Browse the repository at this point in the history
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
  • Loading branch information
Adphi committed Oct 26, 2023
1 parent c8f6699 commit b5118c5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,20 @@ func listImageRepositories(ctx context.Context, reg registry.Registry, name stri
}
l := make(map[string]struct{})
for _, v := range m.Layers {
if _, ok := l[v.Digest.String()]; ok {
continue
}
_, seen := l[v.Digest.String()]
l[v.Digest.String()] = struct{}{}
r.Size += v.Size
if !seen {
r.Size += v.Size
}
if v.MediaType == "application/vnd.lk.registry.layer.v1."+typ {
r.Packages.Size += v.Size
if !seen {
r.Packages.Size += v.Size
}
r.Packages.Count++
} else {
r.Metadata.Size += v.Size
if !seen {
r.Metadata.Size += v.Size
}
r.Metadata.Count++
}
}
Expand Down

0 comments on commit b5118c5

Please sign in to comment.