Skip to content

Commit

Permalink
Fix returncode when deleting a mirror with snapshot
Browse files Browse the repository at this point in the history
When trying to delete a mirror that has snapshot and not providing the
force option, the API should not return a `500
StatusInternalServerError`.
A `403 StatusForbidden` is more appropriate when the condition is
expected by the server.
  • Loading branch information
Crawax authored and reglim committed Aug 18, 2023
1 parent 847fd90 commit 214e907
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ List of contributors, in chronological order:
* Boxjan (https://github.com/boxjan)
* Mauro Regli (https://github.com/reglim)
* Alexander Zubarev (https://github.com/strike)
* Nicolas Dostert (https://github.com/acdn-ndostert)
2 changes: 1 addition & 1 deletion api/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func apiMirrorsDrop(c *gin.Context) {
snapshots := snapshotCollection.ByRemoteRepoSource(repo)

if len(snapshots) > 0 {
return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("won't delete mirror with snapshots, use 'force=1' to override")
return &task.ProcessReturnValue{Code: http.StatusForbidden, Value: nil}, fmt.Errorf("won't delete mirror with snapshots, use 'force=1' to override")
}
}

Expand Down

0 comments on commit 214e907

Please sign in to comment.