@@ -136,33 +136,29 @@ func (c *Checker) start() {
136
136
t := time .NewTicker (c .opts .Interval )
137
137
defer t .Stop ()
138
138
139
- doCheck := func () {
140
- rr ,err := c .update ()
141
- if err != nil {
142
- if xerrors .Is (err ,context .Canceled ) {
143
- return
144
- }
145
- c .log .Error (c .ctx ,"update check failed" ,slog .Error (err ))
146
- }else {
147
- c .notifyIfNewer (r ,rr )
148
- r = rr
149
- }
139
+ diff := time .Until (r .Checked .Add (c .opts .Interval ))
140
+ if diff > 0 {
141
+ c .log .Info (c .ctx ,"time until next update check" ,slog .F ("duration" ,diff ))
142
+ t .Reset (diff )
143
+ }else {
150
144
c .log .Info (c .ctx ,"time until next update check" ,slog .F ("duration" ,c .opts .Interval ))
151
- t .Reset (c .opts .Interval )
152
- }
153
-
154
- if ! r .Checked .IsZero () {
155
- diff := time .Until (r .Checked .Add (c .opts .Interval ))
156
- if diff > 0 {
157
- c .log .Info (c .ctx ,"time until next update check" ,slog .F ("duration" ,diff ))
158
- t .Reset (diff )
159
- }
160
145
}
161
146
162
147
for {
163
148
select {
164
149
case <- t .C :
165
- doCheck ()
150
+ rr ,err := c .update ()
151
+ if err != nil {
152
+ if xerrors .Is (err ,context .Canceled ) {
153
+ return
154
+ }
155
+ c .log .Error (c .ctx ,"update check failed" ,slog .Error (err ))
156
+ }else {
157
+ c .notifyIfNewer (r ,rr )
158
+ r = rr
159
+ }
160
+ c .log .Info (c .ctx ,"time until next update check" ,slog .F ("duration" ,c .opts .Interval ))
161
+ t .Reset (c .opts .Interval )
166
162
case <- c .ctx .Done ():
167
163
return
168
164
}