Skip to content

Commit

Permalink
fix(proto): the size of the repo should be int64, since that is the s…
Browse files Browse the repository at this point in the history
…ame type used for the manifest/config/index/digest sizes it sums up.

Using int32 may result in negative size values when returned by the graphql API

Signed-off-by: Andrei Aaron <[email protected]>
  • Loading branch information
andaaron committed Dec 8, 2023
1 parent 79e1402 commit 8e397dd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/meta/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func AddImageMetaToRepoMeta(repoMeta *proto_go.RepoMeta, repoBlobs *proto_go.Rep
size, platforms, vendors := recalculateAggregateFields(repoMeta, repoBlobs)
repoMeta.Vendors = vendors
repoMeta.Platforms = platforms
repoMeta.Size = int32(size)
repoMeta.Size = size

imageBlobInfo := repoBlobs.Blobs[imageMeta.Digest.String()]
repoMeta.LastUpdatedImage = mConvert.GetProtoEarlierUpdatedImage(repoMeta.LastUpdatedImage,
Expand Down Expand Up @@ -316,7 +316,7 @@ func RemoveImageFromRepoMeta(repoMeta *proto_go.RepoMeta, repoBlobs *proto_go.Re
}
}

repoMeta.Size = int32(updatedSize)
repoMeta.Size = updatedSize
repoMeta.Vendors = updatedVendors
repoMeta.Platforms = updatedPlatforms
repoMeta.LastUpdatedImage = updatedLastImage
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func GetRepoMeta(protoRepoMeta *proto_go.RepoMeta) mTypes.RepoMeta {
Name: protoRepoMeta.Name,
Tags: GetTags(protoRepoMeta.Tags),
Rank: int(protoRepoMeta.Rank),
Size: int64(protoRepoMeta.Size),
Size: protoRepoMeta.Size,
Platforms: GetPlatforms(protoRepoMeta.Platforms),
Vendors: protoRepoMeta.Vendors,
IsStarred: protoRepoMeta.IsStarred,
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/convert/convert_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func GetProtoRepoMeta(repo mTypes.RepoMeta) *proto_go.RepoMeta {
Statistics: GetProtoStatistics(repo.Statistics),
Signatures: GetProtoSignatures(repo.Signatures),
Referrers: GetProtoReferrers(repo.Referrers),
Size: int32(repo.Size),
Size: repo.Size,
Vendors: repo.Vendors,
Platforms: GetProtoPlatforms(repo.Platforms),
LastUpdatedImage: GetProtoLastUpdatedImage(repo.LastUpdatedImage),
Expand Down
6 changes: 3 additions & 3 deletions pkg/meta/proto/gen/meta.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/meta/proto/meta/meta.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ message RepoMeta {

int32 Stars = 9;

int32 Size = 10;
int64 Size = 10;
repeated string Vendors = 11;
repeated oci_v1.Platform Platforms = 12;
optional RepoLastUpdatedImage LastUpdatedImage = 13;
Expand Down

0 comments on commit 8e397dd

Please sign in to comment.