Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0bd68a4

Browse files
committed
Fix logging
1 parent12d712a commit0bd68a4

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
defert.Stop()
138138

139-
doCheck:=func() {
140-
rr,err:=c.update()
141-
iferr!=nil {
142-
ifxerrors.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+
ifdiff>0 {
141+
c.log.Info(c.ctx,"time until next update check",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-
ifdiff>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+
iferr!=nil {
152+
ifxerrors.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)

[8]ページ先頭

©2009-2025 Movatter.jp