Skip to content

Commit

Permalink
fix issue 19392 (#19437)
Browse files Browse the repository at this point in the history
Needs to set the repo when to handle the accessory before subject manifest.

Signed-off-by: wang yan <[email protected]>
  • Loading branch information
wy65701436 authored Oct 12, 2023
1 parent 663d0b8 commit f9ab185
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/server/middleware/subject/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func Middleware() func(http.Handler) http.Handler {
// In certain cases, the OCI client may push the subject artifact and accessory in either order.
// Therefore, it is necessary to handle situations where the client pushes the accessory ahead of the subject artifact.
digest := digest.FromBytes(body)
accs, err := accessory.Mgr.List(ctx, q.New(q.KeyWords{"SubjectArtifactDigest": digest}))
accs, err := accessory.Mgr.List(ctx, q.New(q.KeyWords{"SubjectArtifactDigest": digest, "SubArtifactRepo": info.Repository}))
if err != nil {
logger.Errorf("failed to list accessory artifact: %s, error: %v", digest, err)
return err
Expand Down
2 changes: 2 additions & 0 deletions src/server/middleware/subject/subject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func (suite *MiddlewareTestSuite) addArtAcc(pid, repositoryID int64, repositoryN
ID: 1,
ArtifactID: afid,
SubArtifactDigest: dgt,
SubArtifactRepo: repositoryName,
Digest: accdgt,
Type: accessorymodel.TypeSubject,
})
Expand Down Expand Up @@ -213,6 +214,7 @@ func (suite *MiddlewareTestSuite) TestSubjectAfterAcc() {
accs, err := accessory.Mgr.List(suite.Context(), &q.Query{
Keywords: map[string]interface{}{
"SubjectArtifactDigest": subArtDigest,
"SubjectArtifactRepo": name,
},
})
suite.Equal(1, len(accs))
Expand Down

0 comments on commit f9ab185

Please sign in to comment.