8000 Fix logging · coder/coder@0bd68a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0bd68a4

Browse files
committed
Fix logging
1 parent 12d712a commit 0bd68a4

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

coderd/updatecheck/updatecheck.go

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,33 +136,29 @@ func (c *Checker) start() {
136136
t := time.NewTicker(c.opts.Interval)
137137
defer t.Stop()
138138

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&quo 8000 t;, slog.F("duration", diff))
142+
t.Reset(diff)
143+
} else {
150144
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-
}
160145
}
161146

162147
for {
163148
select {
164149
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)
166162
case <-c.ctx.Done():
167163
return
168164
}

0 commit comments

Comments
 (0)
0