mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 10:28:49 -07:00
Don't consider prereleases for -upgrade (fixes #436)
This commit is contained in:
parent
3640c3b66a
commit
b676264fca
@ -7,9 +7,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 {
|
||||
|
@ -84,7 +84,7 @@ func upgrade() error {
|
||||
}
|
||||
|
||||
func currentRelease() (githubRelease, error) {
|
||||
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 githubRelease{}, err
|
||||
}
|
||||
@ -93,10 +93,13 @@ func currentRelease() (githubRelease, error) {
|
||||
json.NewDecoder(resp.Body).Decode(&rels)
|
||||
resp.Body.Close()
|
||||
|
||||
if len(rels) != 1 {
|
||||
return githubRelease{}, fmt.Errorf("Unexpected number of releases: %d", len(rels))
|
||||
for _, rel := range rels {
|
||||
if !rel.Prerelease {
|
||||
return rel, nil
|
||||
}
|
||||
}
|
||||
return rels[0], nil
|
||||
|
||||
return githubRelease{}, errors.New("no suitable release found")
|
||||
}
|
||||
|
||||
func readTarGZ(url string, dir string) (string, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user