diff options
Diffstat (limited to 'models/packages/container/search.go')
-rw-r--r-- | models/packages/container/search.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/models/packages/container/search.go b/models/packages/container/search.go index 5df35117ce..a513da08b9 100644 --- a/models/packages/container/search.go +++ b/models/packages/container/search.go @@ -25,6 +25,7 @@ type BlobSearchOptions struct { Digest string Tag string IsManifest bool + OnlyLead bool Repository string } @@ -45,6 +46,9 @@ func (opts *BlobSearchOptions) toConds() builder.Cond { if opts.IsManifest { cond = cond.And(builder.Eq{"package_file.lower_name": ManifestFilename}) } + if opts.OnlyLead { + cond = cond.And(builder.Eq{"package_file.is_lead": true}) + } if opts.Digest != "" { var propsCond builder.Cond = builder.Eq{ "package_property.ref_type": packages.PropertyTypeFile, @@ -73,11 +77,9 @@ func GetContainerBlob(ctx context.Context, opts *BlobSearchOptions) (*packages.P pfds, err := getContainerBlobsLimit(ctx, opts, 1) if err != nil { return nil, err - } - if len(pfds) != 1 { + } else if len(pfds) == 0 { return nil, ErrContainerBlobNotExist } - return pfds[0], nil } |