Skip to content

Commit

Permalink
fix: [AH-865]: Fix Repetitive Delete Success | gitness (#3283)
Browse files Browse the repository at this point in the history
* fix: [AH-865]: Fix Lint
* fix: [AH-865]: Fix Repeative Delete Success
  • Loading branch information
ritek01 authored and Harness committed Jan 17, 2025
1 parent 6643c37 commit 57a071c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions registry/app/api/controller/metadata/delete_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ func (c *APIController) DeleteArtifact(ctx context.Context, r artifact.DeleteArt
}

artifactName := string(r.Artifact)
artifactDetails, err := c.ImageStore.GetByName(ctx, regInfo.RegistryID, artifactName)
if err != nil || artifactDetails == nil {
return artifact.DeleteArtifact404JSONResponse{
NotFoundJSONResponse: artifact.NotFoundJSONResponse(
*GetErrorResponse(http.StatusNotFound, "artifact doesn't exist with this key"),
),
}, err
}
if !artifactDetails.Enabled {
return artifact.DeleteArtifact404JSONResponse{
NotFoundJSONResponse: artifact.NotFoundJSONResponse(
*GetErrorResponse(http.StatusNotFound, "artifact is already deleted"),
),
}, nil
}
err = c.tx.WithTx(
ctx, func(ctx context.Context) error {
err = c.disableImageStatus(
Expand Down

0 comments on commit 57a071c

Please sign in to comment.