summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2014-06-17 23:22:19 +0200
committerJakob Borg <jakob@nym.se>2014-06-18 12:54:30 +0200
commitb05fcbc9d72dda356989bad150ada80b690bea64 (patch)
tree839fbf711739859cd64486e238ae643a08cadbe6 /cmd
parentd09c71b688e618c5af438138363b501ea7171dfa (diff)
Simplify usage reporting config options (fixes #370)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/syncthing/gui.go18
-rw-r--r--cmd/syncthing/main.go6
-rw-r--r--cmd/syncthing/usage_report.go5
3 files changed, 10 insertions, 19 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go
index 5e89ca2549..02e68a8093 100644
--- a/cmd/syncthing/gui.go
+++ b/cmd/syncthing/gui.go
@@ -250,30 +250,18 @@ func restPostConfig(req *http.Request, m *model.Model) {
}
}
- if newCfg.Options.UREnabled && !cfg.Options.UREnabled {
+ if newCfg.Options.URAccepted > cfg.Options.URAccepted {
// UR was enabled
- cfg.Options.UREnabled = true
- cfg.Options.URDeclined = false
- cfg.Options.URAccepted = usageReportVersion
- // Set the corresponding options in newCfg so we don't trigger the restart check if this was the only option change
- newCfg.Options.URDeclined = false
newCfg.Options.URAccepted = usageReportVersion
err := sendUsageReport(m)
if err != nil {
l.Infoln("Usage report:", err)
}
go usageReportingLoop(m)
- } else if !newCfg.Options.UREnabled && cfg.Options.UREnabled {
+ } else if newCfg.Options.URAccepted < cfg.Options.URAccepted {
// UR was disabled
- cfg.Options.UREnabled = false
- cfg.Options.URDeclined = true
- cfg.Options.URAccepted = 0
- // Set the corresponding options in newCfg so we don't trigger the restart check if this was the only option change
- newCfg.Options.URDeclined = true
- newCfg.Options.URAccepted = 0
+ newCfg.Options.URAccepted = -1
stopUsageReporting()
- } else {
- cfg.Options.URDeclined = newCfg.Options.URDeclined
}
if !reflect.DeepEqual(cfg.Options, newCfg.Options) || !reflect.DeepEqual(cfg.GUI, newCfg.GUI) {
diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go
index 44114c26fa..dfbb4957de 100644
--- a/cmd/syncthing/main.go
+++ b/cmd/syncthing/main.go
@@ -415,11 +415,11 @@ nextRepo:
}
}
- if cfg.Options.UREnabled && cfg.Options.URAccepted < usageReportVersion {
+ if cfg.Options.URAccepted > 0 && cfg.Options.URAccepted < usageReportVersion {
l.Infoln("Anonymous usage report has changed; revoking acceptance")
- cfg.Options.UREnabled = false
+ cfg.Options.URAccepted = 0
}
- if cfg.Options.UREnabled {
+ if cfg.Options.URAccepted >= usageReportVersion {
go usageReportingLoop(m)
go func() {
time.Sleep(10 * time.Minute)
diff --git a/cmd/syncthing/usage_report.go b/cmd/syncthing/usage_report.go
index 6980c9d6d1..430f9b8b33 100644
--- a/cmd/syncthing/usage_report.go
+++ b/cmd/syncthing/usage_report.go
@@ -107,7 +107,10 @@ loop:
}
func stopUsageReporting() {
- stopUsageReportingCh <- struct{}{}
+ select {
+ case stopUsageReportingCh <- struct{}{}:
+ default:
+ }
}
// Returns CPU performance as a measure of single threaded SHA-256 MiB/s