feat: add editable software download catalog

This commit is contained in:
2026-11-01 22:46:07 +08:00
parent d8e708caec
commit 0820db0a5d
13 changed files with 421 additions and 16 deletions
+11 -3
View File
@@ -170,11 +170,19 @@ func (a *App) putRecord(w http.ResponseWriter, r *http.Request) {
return
}
}
for _, download := range d.Downloads {
if strings.TrimSpace(download.Name) == "" || len(download.Name) > 100 || len(download.Version) > 100 || !webURL(download.URL, false) {
fail(w, 400, "INVALID_INPUT")
if _, provided := fields["downloads"]; !provided {
current, err := a.record("settings", "site")
var existing Settings
if err != nil || decodeData(current.Data, &existing) != nil {
fail(w, 409, "CONFLICT")
return
}
d.Downloads = existing.Downloads
}
d.Downloads = normalizeDownloads(d.Downloads)
if !validDownloads(d.Downloads) {
fail(w, 400, "INVALID_INPUT")
return
}
value = d
}