From 66eb75f49290438a14a0df9477c885bbb2ba7f7e Mon Sep 17 00:00:00 2001 From: Tobias Assarsson Date: Wed, 24 Sep 2025 16:30:06 +0200 Subject: [PATCH] fix repo edit api. --- AUTHORS | 1 + api/repos.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4e4106ac..2ae06a50 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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) diff --git a/api/repos.go b/api/repos.go index 17b8a454..24117aa0 100644 --- a/api/repos.go +++ b/api/repos.go @@ -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