Skip to content

Commit

Permalink
main/config: Prevent to load syncthing along with new config file (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bahadir Yilmaz committed Sep 4, 2018
1 parent 22d8a37 commit eeec711
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/syncthing/main.go
Expand Up @@ -741,6 +741,12 @@ 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(`Syncthing Version Conflict.
Current Syncthing version: %s, Loading config version: %s: `, prevVersion, Version)
}
l.Infoln("Detected upgrade from", prevVersion, "to", Version)
}

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

if cfg.RawCopy().OriginalVersion != config.CurrentVersion {
//check config version
if cfg.RawCopy().OriginalVersion > config.CurrentVersion {
l.Fatalf("Current config version: %d, Loading config version: %d (Config Version Conflict)", 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 eeec711

Please sign in to comment.