mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-07 05:42:42 +00:00
Force flag for API repos delete. #116
This commit is contained in:
+7
-11
@@ -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,10 +136,12 @@ func apiReposDrop(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshots := snapshotCollection.ByLocalRepoSource(repo)
|
if !force {
|
||||||
if len(snapshots) > 0 {
|
snapshots := snapshotCollection.ByLocalRepoSource(repo)
|
||||||
c.Fail(409, fmt.Errorf("unable to drop, local repo has snapshots, use Force to override"))
|
if len(snapshots) > 0 {
|
||||||
return
|
c.Fail(409, fmt.Errorf("unable to drop, local repo has snapshots, use ?force=1 to override"))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = collection.Drop(repo)
|
err = collection.Drop(repo)
|
||||||
|
|||||||
Reference in New Issue
Block a user