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

Commite327dd6

Browse files
committed
Fix edge case where update check has never succeeded
1 parent043f227 commite327dd6

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎coderd/updatecheck.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package coderd
22

33
import (
4+
"database/sql"
45
"net/http"
56

67
"golang.org/x/mod/semver"
8+
"golang.org/x/xerrors"
79

810
"github.com/coder/coder/buildinfo"
911
"github.com/coder/coder/coderd/httpapi"
@@ -13,19 +15,28 @@ import (
1315
func (api*API)updateCheck(rw http.ResponseWriter,r*http.Request) {
1416
ctx:=r.Context()
1517

18+
currentVersion:= codersdk.UpdateCheckResponse{
19+
Current:true,
20+
Version:buildinfo.Version(),
21+
URL:buildinfo.ExternalURL(),
22+
}
23+
1624
ifapi.updateChecker==nil {
1725
// If update checking is disabled, echo the current
1826
// version.
19-
httpapi.Write(ctx,rw,http.StatusOK, codersdk.UpdateCheckResponse{
20-
Current:true,
21-
Version:buildinfo.Version(),
22-
URL:buildinfo.ExternalURL(),
23-
})
27+
httpapi.Write(ctx,rw,http.StatusOK,currentVersion)
2428
return
2529
}
2630

2731
uc,err:=api.updateChecker.Latest(ctx)
2832
iferr!=nil {
33+
ifxerrors.Is(err,sql.ErrNoRows) {
34+
// Update checking is enabled, but has never
35+
// succeeded, reproduce behavior as if disabled.
36+
httpapi.Write(ctx,rw,http.StatusOK,currentVersion)
37+
return
38+
}
39+
2940
httpapi.InternalServerError(rw,err)
3041
return
3142
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp