cmd/syncthing: Handle pre-releases with zero auto upgrade interval (fixes #4090)
This commit is contained in:
parent
ae4206f362
commit
c205fdd77e
@ -923,6 +923,10 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
|
|||||||
l.Infoln("Automatic upgrade is always enabled for candidate releases.")
|
l.Infoln("Automatic upgrade is always enabled for candidate releases.")
|
||||||
if opts.AutoUpgradeIntervalH == 0 || opts.AutoUpgradeIntervalH > 24 {
|
if opts.AutoUpgradeIntervalH == 0 || opts.AutoUpgradeIntervalH > 24 {
|
||||||
opts.AutoUpgradeIntervalH = 12
|
opts.AutoUpgradeIntervalH = 12
|
||||||
|
// Set the option into the config as well, as the auto upgrade
|
||||||
|
// loop expects to read a valid interval from there.
|
||||||
|
cfg.SetOptions(opts)
|
||||||
|
cfg.Save()
|
||||||
}
|
}
|
||||||
// We don't tweak the user's choice of upgrading to pre-releases or
|
// We don't tweak the user's choice of upgrading to pre-releases or
|
||||||
// not, as otherwise they cannot step off the candidate channel.
|
// not, as otherwise they cannot step off the candidate channel.
|
||||||
@ -1241,7 +1245,15 @@ func autoUpgrade(cfg *config.Wrapper) {
|
|||||||
l.Infof("Connected to device %s with a newer version (current %q < remote %q). Checking for upgrades.", data["id"], Version, data["clientVersion"])
|
l.Infof("Connected to device %s with a newer version (current %q < remote %q). Checking for upgrades.", data["id"], Version, data["clientVersion"])
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := cfg.Options()
|
opts := cfg.Options()
|
||||||
|
checkInterval := time.Duration(opts.AutoUpgradeIntervalH) * time.Hour
|
||||||
|
if checkInterval < time.Hour {
|
||||||
|
// We shouldn't be here if AutoUpgradeIntervalH < 1, but for
|
||||||
|
// safety's sake.
|
||||||
|
checkInterval = time.Hour
|
||||||
|
}
|
||||||
|
|
||||||
rel, err := upgrade.LatestRelease(opts.ReleasesURL, Version, opts.UpgradeToPreReleases)
|
rel, err := upgrade.LatestRelease(opts.ReleasesURL, Version, opts.UpgradeToPreReleases)
|
||||||
if err == upgrade.ErrUpgradeUnsupported {
|
if err == upgrade.ErrUpgradeUnsupported {
|
||||||
events.Default.Unsubscribe(sub)
|
events.Default.Unsubscribe(sub)
|
||||||
@ -1251,13 +1263,13 @@ func autoUpgrade(cfg *config.Wrapper) {
|
|||||||
// Don't complain too loudly here; we might simply not have
|
// Don't complain too loudly here; we might simply not have
|
||||||
// internet connectivity, or the upgrade server might be down.
|
// internet connectivity, or the upgrade server might be down.
|
||||||
l.Infoln("Automatic upgrade:", err)
|
l.Infoln("Automatic upgrade:", err)
|
||||||
timer.Reset(time.Duration(cfg.Options().AutoUpgradeIntervalH) * time.Hour)
|
timer.Reset(checkInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if upgrade.CompareVersions(rel.Tag, Version) != upgrade.Newer {
|
if upgrade.CompareVersions(rel.Tag, Version) != upgrade.Newer {
|
||||||
// Skip equal, older or majorly newer (incompatible) versions
|
// Skip equal, older or majorly newer (incompatible) versions
|
||||||
timer.Reset(time.Duration(cfg.Options().AutoUpgradeIntervalH) * time.Hour)
|
timer.Reset(checkInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,7 +1277,7 @@ func autoUpgrade(cfg *config.Wrapper) {
|
|||||||
err = upgrade.To(rel)
|
err = upgrade.To(rel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnln("Automatic upgrade:", err)
|
l.Warnln("Automatic upgrade:", err)
|
||||||
timer.Reset(time.Duration(cfg.Options().AutoUpgradeIntervalH) * time.Hour)
|
timer.Reset(checkInterval)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
events.Default.Unsubscribe(sub)
|
events.Default.Unsubscribe(sub)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user