From 53cf5ca762279f129e5f8c31b1f42c6bd30d228e Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 23 Oct 2014 19:09:53 +0200 Subject: [PATCH] Don't run auto upgrade on non-release builds (fixes #901). --- cmd/syncthing/main.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 921587289..e862b9a91 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -59,6 +59,8 @@ var ( BuildDate time.Time BuildHost = "unknown" BuildUser = "unknown" + IsRelease bool + IsBeta bool LongVersion string GoArchExtra string // "", "v5", "v6", "v7" ) @@ -82,6 +84,13 @@ func init() { } } + // Check for a clean release build. + exp := regexp.MustCompile(`^v\d+\.\d+\.\d+(-beta[\d\.]+)?$`) + IsRelease = exp.MatchString(Version) + + // Check for a beta build + IsBeta = strings.Contains(Version, "-beta") + stamp, _ := strconv.Atoi(BuildStamp) BuildDate = time.Unix(int64(stamp), 0) @@ -291,7 +300,7 @@ func main() { ensureDir(confDir, 0700) if doUpgrade || doUpgradeCheck { - rel, err := upgrade.LatestRelease(strings.Contains(Version, "-beta")) + rel, err := upgrade.LatestRelease(IsBeta) if err != nil { l.Fatalln("Upgrade:", err) // exits 1 } @@ -547,7 +556,11 @@ func syncthingMain() { } if opts.AutoUpgradeIntervalH > 0 { - go autoUpgrade() + if IsRelease { + go autoUpgrade() + } else { + l.Infof("No automatic upgrades; %s is not a relase version.", Version) + } } events.Default.Log(events.StartupComplete, nil) @@ -1192,7 +1205,7 @@ func autoUpgrade() { skipped = true } - rel, err := upgrade.LatestRelease(strings.Contains(Version, "-beta")) + rel, err := upgrade.LatestRelease(IsBeta) if err == upgrade.ErrUpgradeUnsupported { return }