Fix version updates not shown in UI (#5230)
This commit is contained in:
parent
037f46a10d
commit
d78e90822a
6 changed files with 18 additions and 18 deletions
|
|
@ -146,6 +146,9 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
valueChan := make(chan util.Param)
|
||||
go tee.Run(valueChan)
|
||||
|
||||
// capture log messages for UI
|
||||
util.CaptureLogs(valueChan)
|
||||
|
||||
// setup environment
|
||||
if err == nil {
|
||||
err = configureEnvironment(cmd, conf)
|
||||
|
|
@ -241,10 +244,7 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
|
||||
// show and check version
|
||||
valueChan <- util.Param{Key: "version", Val: server.FormattedVersion()}
|
||||
go updater.Run(log, httpd, tee, valueChan)
|
||||
|
||||
// capture log messages for UI
|
||||
util.CaptureLogs(valueChan)
|
||||
go updater.Run(log, httpd, valueChan)
|
||||
|
||||
// expose sponsor to UI
|
||||
if sponsor.Subject != "" {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import (
|
|||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
var ignoreState = []string{"releaseNotes"} // excessive size
|
||||
|
||||
func indexHandler() http.HandlerFunc {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
|
||||
|
|
@ -173,7 +175,7 @@ func boolGetHandler(get func() bool) http.HandlerFunc {
|
|||
func stateHandler(cache *util.Cache) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
res := cache.State()
|
||||
for _, k := range []string{"availableVersion", "releaseNotes"} {
|
||||
for _, k := range ignoreState {
|
||||
delete(res, k)
|
||||
}
|
||||
jsonResult(w, res)
|
||||
|
|
|
|||
|
|
@ -9,12 +9,16 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/server"
|
||||
"github.com/google/go-github/v32/github"
|
||||
"github.com/hashicorp/go-version"
|
||||
)
|
||||
|
||||
const timeout = 30 * time.Second
|
||||
const (
|
||||
owner = "evcc-io"
|
||||
repository = "evcc"
|
||||
|
||||
timeout = 30 * time.Second
|
||||
)
|
||||
|
||||
// Repo is a github repository adapter
|
||||
type Repo struct {
|
||||
|
|
@ -73,7 +77,7 @@ func (r *Repo) ReleaseNotes(from string) (rendered string, err error) {
|
|||
var md string
|
||||
if md, _, err = r.Markdown(context.Background(), notes, &github.MarkdownOptions{
|
||||
Mode: "gfm",
|
||||
Context: fmt.Sprintf("%s/%s", server.Owner, server.Repository),
|
||||
Context: fmt.Sprintf("%s/%s", r.owner, r.repository),
|
||||
}); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ import (
|
|||
)
|
||||
|
||||
// Run regularly checks version
|
||||
func Run(log *util.Logger, httpd webServer, tee util.TeeAttacher, outChan chan<- util.Param) {
|
||||
func Run(log *util.Logger, httpd webServer, outChan chan<- util.Param) {
|
||||
u := &watch{
|
||||
log: log,
|
||||
outChan: outChan,
|
||||
repo: NewRepo(server.Owner, server.Repository),
|
||||
repo: NewRepo(owner, repository),
|
||||
}
|
||||
|
||||
c := make(chan *github.RepositoryRelease, 1)
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ import (
|
|||
var latest *github.RepositoryRelease
|
||||
|
||||
// Run regularly checks version
|
||||
func Run(log *util.Logger, httpd webServer, tee util.TeeAttacher, outChan chan<- util.Param) {
|
||||
func Run(log *util.Logger, httpd webServer, outChan chan<- util.Param) {
|
||||
u := &watch{
|
||||
log: log,
|
||||
outChan: outChan,
|
||||
repo: NewRepo(server.Owner, server.Repository),
|
||||
repo: NewRepo(owner, repository),
|
||||
}
|
||||
|
||||
httpd.Router().PathPrefix("/api/update").HandlerFunc(u.updateHandler)
|
||||
|
|
|
|||
|
|
@ -3,12 +3,6 @@ package server
|
|||
import "fmt"
|
||||
|
||||
var (
|
||||
// Repository name
|
||||
Repository = "evcc"
|
||||
|
||||
// Owner of repository
|
||||
Owner = "andig"
|
||||
|
||||
// Version of executable
|
||||
Version = "0.0.1-alpha"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue