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

This commit is contained in:
Jakob Borg 2023-08-09 20:55:17 +02:00
parent b347c14bd1
commit 462389934b
2 changed files with 11 additions and 1 deletions

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)

View File

@ -35,7 +35,7 @@ type Asset struct {
// The browser URL is needed for human readable links in the output created
// by cmd/stupgrades.
BrowserURL string `json:"browser_download_url"`
BrowserURL string `json:"browser_download_url,omitempty"`
}
var (