diff options
author | Jakob Borg <jakob@kastelo.net> | 2023-08-09 20:55:17 +0200 |
---|---|---|
committer | Jakob Borg <jakob@kastelo.net> | 2023-08-09 21:01:15 +0200 |
commit | 462389934b87eb1b2e2deb8b2b19cc504b449c3a (patch) | |
tree | a9599d9cda4b84236d331f778a3a0a6dd22c25f0 | |
parent | b347c14bd19a29e453d53da96a522125d5b6b238 (diff) | |
download | syncthing-462389934b87eb1b2e2deb8b2b19cc504b449c3a.tar.gz syncthing-462389934b87eb1b2e2deb8b2b19cc504b449c3a.zip |
cmd/stupgrades: Serve friendlier URLs for upgrade assets (fixes #9033)
-rw-r--r-- | cmd/stupgrades/main.go | 10 | ||||
-rw-r--r-- | lib/upgrade/upgrade_common.go | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/cmd/stupgrades/main.go b/cmd/stupgrades/main.go index 66c40dc29..3e4da7966 100644 --- a/cmd/stupgrades/main.go +++ b/cmd/stupgrades/main.go @@ -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) diff --git a/lib/upgrade/upgrade_common.go b/lib/upgrade/upgrade_common.go index d72a535f7..fae85145b 100644 --- a/lib/upgrade/upgrade_common.go +++ b/lib/upgrade/upgrade_common.go @@ -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 ( |