* auto-update: use 'selfupdate_min_version' from version.json

This commit is contained in:
Simon Zolin 2019-06-05 14:07:32 +03:00
parent ddb1bc0fee
commit 466f553bbe
2 changed files with 5 additions and 2 deletions

View File

@ -250,6 +250,8 @@ Example of version.json data:
"selfupdate_min_version": "v0.0"
}
Server can only auto-update if the current version is equal or higher than `selfupdate_min_version`.
Request:
GET /control/version.json

View File

@ -34,13 +34,14 @@ func getVersionResp(data []byte) []byte {
ret["new_version"], ok1 = versionJSON["version"].(string)
ret["announcement"], ok2 = versionJSON["announcement"].(string)
ret["announcement_url"], ok3 = versionJSON["announcement_url"].(string)
if !ok1 || !ok2 || !ok3 {
selfUpdateMinVersion, ok4 := versionJSON["selfupdate_min_version"].(string)
if !ok1 || !ok2 || !ok3 || !ok4 {
log.Error("version.json: invalid data")
return []byte{}
}
_, ok := versionJSON[fmt.Sprintf("download_%s_%s", runtime.GOOS, runtime.GOARCH)]
if ok && ret["new_version"] != VersionString {
if ok && ret["new_version"] != VersionString && VersionString >= selfUpdateMinVersion {
ret["can_autoupdate"] = true
}