fix repo edit api.

This commit is contained in:
Tobias Assarsson
2025-09-24 16:30:06 +02:00
parent d3bed7830c
commit 66eb75f492
2 changed files with 5 additions and 3 deletions

View File

@@ -72,3 +72,4 @@ List of contributors, in chronological order:
* Itay Porezky (https://github.com/itayporezky)
* JupiterRider (https://github.com/JupiterRider)
* Agustin Henze (https://github.com/agustinhenze)
* Tobias Assarsson (https://github.com/daedaluz)

View File

@@ -195,17 +195,18 @@ func apiReposEdit(c *gin.Context) {
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
}
if b.Name != nil {
if b.Name != nil && *b.Name != name {
_, err := collection.ByName(*b.Name)
if err == nil {
// already exists
AbortWithJSONError(c, 404, err)
AbortWithJSONError(c, 404, fmt.Errorf("local repo with name %q already exists", *b.Name))
return
}
repo.Name = *b.Name