From c8123bda288c5b7dc893b165278df6bad905ed2c Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 21 Dec 2018 15:26:36 +0100 Subject: [PATCH] cmd/syncthing: Don't rewrite config on startup unless necessary (#5399) --- cmd/syncthing/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 870f7b175..34da14132 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -840,13 +840,16 @@ func syncthingMain(runtimeOptions RuntimeOptions) { if opts := cfg.Options(); IsCandidate { l.Infoln("Anonymous usage reporting is always enabled for candidate releases.") - opts.URAccepted = usageReportVersion - cfg.SetOptions(opts) - cfg.Save() - // Unique ID will be set and config saved below if necessary. + if opts.URAccepted != usageReportVersion { + opts.URAccepted = usageReportVersion + cfg.SetOptions(opts) + cfg.Save() + // Unique ID will be set and config saved below if necessary. + } } - if opts := cfg.Options(); opts.URUniqueID == "" { + // If we are going to do usage reporting, ensure we have a valid unique ID. + if opts := cfg.Options(); opts.URAccepted > 0 && opts.URUniqueID == "" { opts.URUniqueID = rand.String(8) cfg.SetOptions(opts) cfg.Save()