mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-30 04:20:53 +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
|
||||
}
|
||||
|
||||
// Pre-task validation of new name if provided
|
||||
if b.Name != "" {
|
||||
// Pre-task validation of new name if provided (skip if renaming to same name)
|
||||
if b.Name != "" && b.Name != name {
|
||||
_, err = collection.ByName(b.Name)
|
||||
if err == nil {
|
||||
AbortWithJSONError(c, 409, fmt.Errorf("unable to rename: snapshot %s already exists", b.Name))
|
||||
|
||||
Reference in New Issue
Block a user