Don't run auto upgrade on non-release builds (fixes #901).

This commit is contained in:
Jakob Borg 2014-10-23 19:09:53 +02:00
parent b5ef42b0a1
commit 53cf5ca762

View File

@ -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
}