mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-31 04:30:44 +00:00
fix(snapshot): allow same-name in pre-task check for update
The pre-task validation in apiSnapshotsUpdate was incorrectly rejecting PUT requests that set the Name to the snapshot's current name. This caused a 409 response before creating a task, which broke the system test SnapshotsAPITestCreateUpdate that expects a task to be created and then fail inside the task. The fix restores the 'b.Name != name' condition in the pre-task check so that same-name updates pass through to the task, where the in-task duplicate check will properly fail them (returning a failed task state instead of a direct 409).
This commit is contained in:
+2
-2
@@ -339,8 +339,8 @@ func apiSnapshotsUpdate(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-task validation of new name if provided
|
// Pre-task validation of new name if provided (skip if renaming to same name)
|
||||||
if b.Name != "" {
|
if b.Name != "" && b.Name != name {
|
||||||
_, err = collection.ByName(b.Name)
|
_, err = collection.ByName(b.Name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
AbortWithJSONError(c, 409, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name))
|
AbortWithJSONError(c, 409, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name))
|
||||||
|
|||||||
Reference in New Issue
Block a user