Add a Check for updates button under Settings; keep the self edge when settings are saved
CI / test (push) Successful in 4m48s
CI / test (push) Successful in 4m48s
Saving settings replaced the whole Settings value, which would have dropped SelfEdgeID and made the next start create a second self edge with a new token. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da3d7201a1
commit
abf352e6c9
10 files changed
+135
-1
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package hammerhead
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.veillax.com/Veillax/reef/selfupdate"
|
||||
)
|
||||
|
||||
// checkUpdate asks the release server whether a newer Hammerhead exists. It only looks: updating is
|
||||
// left to auto-update or to the person running the server.
|
||||
func (s *Server) checkUpdate(w http.ResponseWriter, r *http.Request, p *principal) {
|
||||
o := s.opts
|
||||
cfg := selfupdate.Config{Server: o.UpdateServer, Repo: o.UpdateRepo, App: "hammerhead", Current: o.Version}
|
||||
if cfg.Server == "" {
|
||||
cfg.Server = "https://git.veillax.com"
|
||||
}
|
||||
if cfg.Repo == "" {
|
||||
cfg.Repo = "Veillax/hammerhead"
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second)
|
||||
defer cancel()
|
||||
out := map[string]any{"current": o.Version, "autoUpdate": o.AutoUpdate, "checked": time.Now()}
|
||||
latest, newer, err := selfupdate.Check(ctx, cfg)
|
||||
out["latest"], out["newer"] = latest, newer
|
||||
if err != nil {
|
||||
out["error"] = err.Error()
|
||||
}
|
||||
writeJSON(w, 200, out)
|
||||
}
|
||||
Reference in new issue
Block a user