address comment
This commit is contained in:
parent
e55fbf2475
commit
75500c8855
|
|
@ -265,7 +265,7 @@ func (s *Server) Handler() http.Handler {
|
|||
}()
|
||||
|
||||
w.Header().Set("X-Frame-Options", "DENY")
|
||||
w.Header().Set("X-Version", version.GetVersion())
|
||||
w.Header().Set("X-Version", version.Version)
|
||||
w.Header().Set("X-Request-ID", requestID)
|
||||
|
||||
ctx := r.Context()
|
||||
|
|
@ -1564,6 +1564,8 @@ func (s *Server) modelUpstream(w http.ResponseWriter, r *http.Request) error {
|
|||
}
|
||||
|
||||
func (s *Server) checkForUpdate(w http.ResponseWriter, r *http.Request) error {
|
||||
currentVersion := version.Version
|
||||
|
||||
if s.Updater == nil {
|
||||
return fmt.Errorf("updater not available")
|
||||
}
|
||||
|
|
@ -1574,9 +1576,6 @@ func (s *Server) checkForUpdate(w http.ResponseWriter, r *http.Request) error {
|
|||
// Don't return error, just log it and continue with no update available
|
||||
}
|
||||
|
||||
// Get current version with fallbacks for development
|
||||
currentVersion := version.GetVersion()
|
||||
|
||||
response := responses.UpdateCheckResponse{
|
||||
UpdateInfo: responses.UpdateInfo{
|
||||
CurrentVersion: currentVersion,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func (u *Updater) checkForUpdate(ctx context.Context) (bool, UpdateResponse) {
|
|||
query := requestURL.Query()
|
||||
query.Add("os", runtime.GOOS)
|
||||
query.Add("arch", runtime.GOARCH)
|
||||
currentVersion := version.GetVersion()
|
||||
currentVersion := version.Version
|
||||
query.Add("version", currentVersion)
|
||||
query.Add("ts", strconv.FormatInt(time.Now().Unix(), 10))
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ func (u *Updater) checkForUpdate(ctx context.Context) (bool, UpdateResponse) {
|
|||
if signature != "" {
|
||||
req.Header.Set("Authorization", signature)
|
||||
}
|
||||
ua := fmt.Sprintf("ollama/%s %s Go/%s %s", version.GetVersion(), runtime.GOARCH, runtime.Version(), UserAgentOS)
|
||||
ua := fmt.Sprintf("ollama/%s %s Go/%s %s", version.Version, runtime.GOARCH, runtime.Version(), UserAgentOS)
|
||||
req.Header.Set("User-Agent", ua)
|
||||
|
||||
slog.Debug("checking for available update", "requestURL", requestURL, "User-Agent", ua)
|
||||
|
|
@ -305,7 +305,13 @@ func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(str
|
|||
// Regular interval check
|
||||
}
|
||||
|
||||
// Check if auto-update is enabled
|
||||
// Always check for updates
|
||||
available, resp := u.checkForUpdate(ctx)
|
||||
if !available {
|
||||
continue
|
||||
}
|
||||
|
||||
// Update is available - check if auto-update is enabled
|
||||
settings, err := u.Store.Settings()
|
||||
if err != nil {
|
||||
slog.Error("failed to load settings", "error", err)
|
||||
|
|
@ -313,22 +319,19 @@ func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(str
|
|||
}
|
||||
|
||||
if !settings.AutoUpdateEnabled {
|
||||
// When auto-update is disabled, don't check or download anything
|
||||
slog.Debug("auto-update disabled, skipping check")
|
||||
// Auto-update disabled - don't download, just log
|
||||
slog.Debug("update available but auto-update disabled", "version", resp.UpdateVersion)
|
||||
continue
|
||||
}
|
||||
|
||||
// Auto-update is enabled - proceed with normal flow
|
||||
available, resp := u.checkForUpdate(ctx)
|
||||
if available {
|
||||
err := u.DownloadNewRelease(ctx, resp)
|
||||
// Auto-update is enabled - download and notify
|
||||
err = u.DownloadNewRelease(ctx, resp)
|
||||
if err != nil {
|
||||
slog.Error("failed to download new release", "error", err)
|
||||
} else {
|
||||
err = cb(resp.UpdateVersion)
|
||||
if err != nil {
|
||||
slog.Error("failed to download new release", "error", err)
|
||||
} else {
|
||||
err = cb(resp.UpdateVersion)
|
||||
if err != nil {
|
||||
slog.Warn("failed to register update available with tray", "error", err)
|
||||
}
|
||||
slog.Warn("failed to register update available with tray", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,39 +2,4 @@
|
|||
|
||||
package version
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var Version string = "0.0.0"
|
||||
|
||||
// GetVersion returns the version, with fallback to git or build info
|
||||
func GetVersion() string {
|
||||
// If version is set via ldflags, use it
|
||||
if Version != "" && Version != "0.0.0" {
|
||||
return Version
|
||||
}
|
||||
|
||||
// Try to get from build info
|
||||
if buildinfo, ok := debug.ReadBuildInfo(); ok {
|
||||
if buildinfo.Main.Version != "" && buildinfo.Main.Version != "(devel)" {
|
||||
return buildinfo.Main.Version
|
||||
}
|
||||
}
|
||||
|
||||
// In development, try to get from git
|
||||
if cmd := exec.Command("git", "describe", "--tags", "--first-parent", "--abbrev=7", "--long", "--dirty", "--always"); cmd != nil {
|
||||
if output, err := cmd.Output(); err == nil {
|
||||
version := strings.TrimSpace(string(output))
|
||||
version = strings.TrimPrefix(version, "v")
|
||||
if version != "" {
|
||||
return version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback
|
||||
return "dev"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue