Skip to content

Commit

Permalink
do not delete accessory relationship while still referenced (#20360)
Browse files Browse the repository at this point in the history
Signed-off-by: yminer <yminer@vmware.com>
Co-authored-by: Wang Yan <wangyan@vmware.com>
  • Loading branch information
MinerYang and wy65701436 committed Apr 30, 2024
1 parent d154c27 commit d01dfd4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/controller/artifact/controller.go
Expand Up @@ -326,12 +326,6 @@ func (c *controller) deleteDeeply(ctx context.Context, id int64, isRoot, isAcces
return err
}

if isAccessory {
if err := c.accessoryMgr.DeleteAccessories(ctx, q.New(q.KeyWords{"ArtifactID": art.ID, "Digest": art.Digest})); err != nil && !errors.IsErr(err, errors.NotFoundCode) {
return err
}
}

// the child artifact is referenced by some tags, skip
if !isRoot && len(art.Tags) > 0 {
return nil
Expand All @@ -354,6 +348,12 @@ func (c *controller) deleteDeeply(ctx context.Context, id int64, isRoot, isAcces
return nil
}

if isAccessory {
if err := c.accessoryMgr.DeleteAccessories(ctx, q.New(q.KeyWords{"ArtifactID": art.ID, "Digest": art.Digest})); err != nil && !errors.IsErr(err, errors.NotFoundCode) {
return err
}
}

// delete accessories if contains any
for _, acc := range art.Accessories {
// only hard ref accessory should be removed
Expand Down

0 comments on commit d01dfd4

Please sign in to comment.