mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-16 12:08:04 +00:00
Force flag for API repos delete. #116
This commit is contained in:
+4
-8
@@ -110,13 +110,7 @@ func apiReposShow(c *gin.Context) {
|
|||||||
|
|
||||||
// DELETE /api/repos/:name
|
// DELETE /api/repos/:name
|
||||||
func apiReposDrop(c *gin.Context) {
|
func apiReposDrop(c *gin.Context) {
|
||||||
var b struct {
|
force := c.Request.URL.Query().Get("force") == "1"
|
||||||
Force bool
|
|
||||||
}
|
|
||||||
|
|
||||||
if !c.Bind(&b) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
collection := context.CollectionFactory().LocalRepoCollection()
|
collection := context.CollectionFactory().LocalRepoCollection()
|
||||||
collection.Lock()
|
collection.Lock()
|
||||||
@@ -142,11 +136,13 @@ func apiReposDrop(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !force {
|
||||||
snapshots := snapshotCollection.ByLocalRepoSource(repo)
|
snapshots := snapshotCollection.ByLocalRepoSource(repo)
|
||||||
if len(snapshots) > 0 {
|
if len(snapshots) > 0 {
|
||||||
c.Fail(409, fmt.Errorf("unable to drop, local repo has snapshots, use Force to override"))
|
c.Fail(409, fmt.Errorf("unable to drop, local repo has snapshots, use ?force=1 to override"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = collection.Drop(repo)
|
err = collection.Drop(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user