From 466f553bbecf32e85ee3ad9513d6d39de018b8f8 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 5 Jun 2019 14:07:32 +0300 Subject: [PATCH] * auto-update: use 'selfupdate_min_version' from version.json --- AGHTechDoc.md | 2 ++ control_update.go | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/AGHTechDoc.md b/AGHTechDoc.md index f4e4d4c7..167b9caa 100644 --- a/AGHTechDoc.md +++ b/AGHTechDoc.md @@ -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 diff --git a/control_update.go b/control_update.go index 987457da..563c5d0f 100644 --- a/control_update.go +++ b/control_update.go @@ -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 }