diff --git a/api/mirror.go b/api/mirror.go index 7e46b5b4..e30c9afc 100644 --- a/api/mirror.go +++ b/api/mirror.go @@ -548,7 +548,8 @@ func apiMirrorsUpdate(c *gin.Context) { collectionFactory := context.NewCollectionFactory() collection := collectionFactory.RemoteRepoCollection() - remote, err = collection.ByName(c.Params.ByName("name")) + name := c.Params.ByName("name") + remote, err = collection.ByName(name) if err != nil { AbortWithJSONError(c, 404, err) return @@ -584,8 +585,8 @@ func apiMirrorsUpdate(c *gin.Context) { taskCollectionFactory := context.NewCollectionFactory() taskCollection := taskCollectionFactory.RemoteRepoCollection() - // Fresh load after lock acquired - remote, err := taskCollection.ByName(c.Params.ByName("name")) + // Fresh load after lock acquired (use captured `name` variable, not gin context) + remote, err := taskCollection.ByName(name) if err != nil { return &task.ProcessReturnValue{Code: http.StatusInternalServerError, Value: nil}, fmt.Errorf("unable to update: %s", err) } diff --git a/api/repos.go b/api/repos.go index 05452890..04e6f191 100644 --- a/api/repos.go +++ b/api/repos.go @@ -419,7 +419,8 @@ func apiReposPackagesAddDelete(c *gin.Context, taskNamePrefix string, cb func(li collectionFactory := context.NewCollectionFactory() collection := collectionFactory.LocalRepoCollection() - repo, err := collection.ByName(c.Params.ByName("name")) + name := c.Params.ByName("name") + repo, err := collection.ByName(name) if err != nil { AbortWithJSONError(c, 404, err) return @@ -432,8 +433,8 @@ func apiReposPackagesAddDelete(c *gin.Context, taskNamePrefix string, cb func(li taskCollectionFactory := context.NewCollectionFactory() taskCollection := taskCollectionFactory.LocalRepoCollection() - // Fresh load after lock acquired - repo, err := taskCollection.ByName(c.Params.ByName("name")) + // Fresh load after lock acquired (use captured `name` variable, not gin context) + repo, err := taskCollection.ByName(name) if err != nil { return &task.ProcessReturnValue{Code: http.StatusNotFound, Value: nil}, err }