diff options
author | Jakob Borg <jakob@nym.se> | 2014-07-24 12:59:51 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-07-24 12:59:51 +0200 |
commit | 6065b6cb93b1f5576107b47de14d8f1f74cd8779 (patch) | |
tree | 852d4ae0edeadd7cea0bdde42cb3d6fa06950b67 | |
parent | 58cc108c0cfad9a7a507ace70ab4cfb3eb96c304 (diff) |
-rw-r--r-- | cmd/syncthing/upgrade_supported.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/cmd/syncthing/upgrade_supported.go b/cmd/syncthing/upgrade_supported.go index c7f70c57f4..05e61c4ce3 100644 --- a/cmd/syncthing/upgrade_supported.go +++ b/cmd/syncthing/upgrade_supported.go @@ -27,9 +27,9 @@ import ( ) type githubRelease struct { - Tag string `json:"tag_name"` - Prelease bool `json:"prerelease"` - Assets []githubAsset `json:"assets"` + Tag string `json:"tag_name"` + Prerelease bool `json:"prerelease"` + Assets []githubAsset `json:"assets"` } type githubAsset struct { @@ -49,7 +49,7 @@ func upgrade() error { return err } - resp, err := http.Get("https://api.github.com/repos/calmh/syncthing/releases?per_page=1") + resp, err := http.Get("https://api.github.com/repos/calmh/syncthing/releases?per_page=10") if err != nil { return err } @@ -58,10 +58,17 @@ func upgrade() error { json.NewDecoder(resp.Body).Decode(&rels) resp.Body.Close() - if len(rels) != 1 { - return fmt.Errorf("Unexpected number of releases: %d", len(rels)) + var rel githubRelease + for _, trel := range rels { + if !trel.Prerelease { + rel = trel + break + } + } + + if len(rel.Tag) == 0 { + return errors.New("no suitable release found") } - rel := rels[0] switch compareVersions(rel.Tag, Version) { case -1: |