keep existing repo_type on explicit empty PUT; repair wiped locals as local
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful

This commit is contained in:
2026-11-01 15:20:58 +11:00
parent 98bee14385
commit f28fb21705
3 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -135,13 +135,15 @@ func (h *RemotesHandler) update(w http.ResponseWriter, r *http.Request) {
if oldKnown {
remote.MutableTTL = existing.MutableTTL
remote.QuarantineDays = existing.QuarantineDays
remote.RepoType = existing.RepoType
}
if err := json.NewDecoder(r.Body).Decode(&remote); err != nil {
http.Error(w, "invalid json", http.StatusBadRequest)
return
}
remote.Name = name
if remote.RepoType == "" && oldKnown {
remote.RepoType = existing.RepoType
}
if remote.RepoType == "" {
remote.RepoType = models.RepoTypeRemote
}
+1
View File
@@ -201,6 +201,7 @@ func TestRepoTypeKeptOnUpdate(t *testing.T) {
{"PUT", "/rt-remote", `{` + body + `}`, 200, "rt-remote", "remote"},
{"POST", "/", `{"name":"rt-local","package_type":"rpm","repo_type":"local"}`, 201, "rt-local", "local"},
{"PUT", "/rt-local", `{"package_type":"rpm","description":"x"}`, 200, "rt-local", "local"},
{"PUT", "/rt-local", `{"package_type":"rpm","repo_type":""}`, 200, "rt-local", "local"},
{"PUT", "/rt-local", `{"package_type":"rpm","repo_type":"bogus"}`, 400, "rt-local", "local"},
} {
if c := do(t, h, s.method, s.path, s.json); c != s.code {
+1 -1
View File
@@ -1 +1 @@
UPDATE remotes SET repo_type = 'remote' WHERE repo_type = '' OR repo_type IS NULL;
UPDATE remotes SET repo_type = CASE WHEN COALESCE(base_url, '') = '' THEN 'local' ELSE 'remote' END WHERE repo_type = '' OR repo_type IS NULL;