cmd/stupgrades: Serve friendlier URLs for upgrade assets (fixes #9033)

This commit is contained in:
Jakob Borg
2023-08-09 21:01:15 +02:00
parent b347c14bd1
commit 462389934b
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -68,6 +68,16 @@ func (p *githubReleases) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
sort.Sort(upgrade.SortByRelease(rels))
rels = filterForLatest(rels)
// Move the URL used for browser downloads to the URL field, and remove
// the browser URL field. This avoids going via the GitHub API for
// downloads, since Syncthing uses the URL field.
for _, rel := range rels {
for j, asset := range rel.Assets {
rel.Assets[j].URL = asset.BrowserURL
rel.Assets[j].BrowserURL = ""
}
}
buf := new(bytes.Buffer)
_ = json.NewEncoder(buf).Encode(rels)