Skip to content

Commit c8123bd

Browse files
calmhAudriusButkevicius
authored andcommitted
cmd/syncthing: Don't rewrite config on startup unless necessary (syncthing#5399)
1 parent 99c9d65 commit c8123bd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cmd/syncthing/main.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,13 +840,16 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
840840

841841
if opts := cfg.Options(); IsCandidate {
842842
l.Infoln("Anonymous usage reporting is always enabled for candidate releases.")
843-
opts.URAccepted = usageReportVersion
844-
cfg.SetOptions(opts)
845-
cfg.Save()
846-
// Unique ID will be set and config saved below if necessary.
843+
if opts.URAccepted != usageReportVersion {
844+
opts.URAccepted = usageReportVersion
845+
cfg.SetOptions(opts)
846+
cfg.Save()
847+
// Unique ID will be set and config saved below if necessary.
848+
}
847849
}
848850

849-
if opts := cfg.Options(); opts.URUniqueID == "" {
851+
// If we are going to do usage reporting, ensure we have a valid unique ID.
852+
if opts := cfg.Options(); opts.URAccepted > 0 && opts.URUniqueID == "" {
850853
opts.URUniqueID = rand.String(8)
851854
cfg.SetOptions(opts)
852855
cfg.Save()

0 commit comments

Comments
 (0)