diff options
author | tomasz1986 <twilczynski@naver.com> | 2023-07-22 23:25:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-22 21:25:03 +0000 |
commit | f42f041f5329f08117624d79fe25ed5e695f5e85 (patch) | |
tree | 2333e2567d5ca90cdf3c971231e69b11f71e3184 | |
parent | 6b6b2c6194509d21abd80ada4f4d8c0a2288a146 (diff) | |
download | syncthing-f42f041f5329f08117624d79fe25ed5e695f5e85.tar.gz syncthing-f42f041f5329f08117624d79fe25ed5e695f5e85.zip |
lib/ur: Don't report uptime if start time is in the past (fixes #7698) (#8996)
Currently, because of devices with unset RTC clock, the 100% percentile
for Uptime on [1] is calculated since the Unix epoch which is useless as
far as usage statistics are concerned. Thus, if the Syncthing start time
is set to a past date, assume that the clock is wrong and do not even
try to report the uptime.
[1] https://data.syncthing.net
Signed-off-by: Tomasz WilczyĆski <twilczynski@naver.com>
Co-authored-by: Jakob Borg <jakob@kastelo.net>
-rw-r--r-- | lib/ur/usage_report.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ur/usage_report.go b/lib/ur/usage_report.go index 9b5cccddf..ce6984a4c 100644 --- a/lib/ur/usage_report.go +++ b/lib/ur/usage_report.go @@ -328,6 +328,11 @@ func (s *Service) reportData(ctx context.Context, urVersion int, preview bool) ( } func (*Service) UptimeS() int { + // Handle nonexistent or wildly incorrect system clock. + // This code was written in 2023, it can't run in the past. + if StartTime.Year() < 2023 { + return 0 + } return int(time.Since(StartTime).Seconds()) } |