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

Commit94accc8

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

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎coderd/updatecheck.go

Lines changed: 15 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,27 @@ 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+
// If update checking is disabled, echo the current
35+
// version.
36+
httpapi.Write(ctx,rw,http.StatusOK,currentVersion)
37+
return
38+
}
2939
httpapi.InternalServerError(rw,err)
3040
return
3141
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp