Skip to content

Commit

Permalink
cmd/main: Prevent to load syncthing along with new config file (fixes s…
Browse files Browse the repository at this point in the history
  • Loading branch information
Bahadir Yilmaz committed Sep 5, 2018
1 parent 22d8a37 commit 928a11a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/syncthing/main.go
Expand Up @@ -741,6 +741,11 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
curParts := strings.Split(Version, "-")
if prevParts[0] != curParts[0] {
if prevVersion != "" {
//Check Syncthing version is wheather downgrading
l.Infof("Current Syncthing %s, Loadind %s", prevVersion, Version)
if upgrade.CompareVersions(curParts[0], prevParts[0]) == upgrade.Older || upgrade.CompareVersions(curParts[0], prevParts[0]) == upgrade.MajorOlder {
l.Infof("Current Syncthing Version: %s, Loading Syncthing Version: %s: (Syncthing Version Mismatch)", prevVersion, Version)
}
l.Infoln("Detected upgrade from", prevVersion, "to", Version)
}

Expand Down Expand Up @@ -965,6 +970,12 @@ func loadConfigAtStartup() *config.Wrapper {
}

if cfg.RawCopy().OriginalVersion != config.CurrentVersion {
//check config version
if cfg.RawCopy().OriginalVersion > config.CurrentVersion {
l.Fatalf("Current Configuration Version: %d, Loading Configuration Version: %d (Configuration Version Mismatch)", cfg.RawCopy().OriginalVersion, config.CurrentVersion)
//Config version is not compatible with installed version
os.Exit(exitError)
}
err = archiveAndSaveConfig(cfg)
if err != nil {
l.Fatalln("Config archive:", err)
Expand Down

0 comments on commit 928a11a

Please sign in to comment.