mirror of
https://github.com/ollama/ollama.git
synced 2026-03-09 03:12:11 -05:00
fix: window app crash on startup when update is pending (#14451)
This commit is contained in:
@@ -296,8 +296,15 @@ func main() {
|
|||||||
|
|
||||||
// Check for pending updates on startup (show tray notification if update is ready)
|
// Check for pending updates on startup (show tray notification if update is ready)
|
||||||
if updater.IsUpdatePending() {
|
if updater.IsUpdatePending() {
|
||||||
slog.Debug("update pending on startup, showing tray notification")
|
// On Windows, the tray is initialized in osRun(). Calling UpdateAvailable
|
||||||
UpdateAvailable("")
|
// before that would dereference a nil tray callback.
|
||||||
|
// TODO: refactor so the update check runs after platform init on all platforms.
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
slog.Debug("update pending on startup, deferring tray notification until tray initialization")
|
||||||
|
} else {
|
||||||
|
slog.Debug("update pending on startup, showing tray notification")
|
||||||
|
UpdateAvailable("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasCompletedFirstRun, err := st.HasCompletedFirstRun()
|
hasCompletedFirstRun, err := st.HasCompletedFirstRun()
|
||||||
|
|||||||
@@ -154,6 +154,10 @@ func handleURLSchemeRequest(urlScheme string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateAvailable(ver string) error {
|
func UpdateAvailable(ver string) error {
|
||||||
|
if app.t == nil {
|
||||||
|
slog.Debug("tray not yet initialized, skipping update notification")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return app.t.UpdateAvailable(ver)
|
return app.t.UpdateAvailable(ver)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +169,14 @@ func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) {
|
|||||||
log.Fatalf("Failed to start: %s", err)
|
log.Fatalf("Failed to start: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for pending updates now that the tray is initialized.
|
||||||
|
// The platform-independent check in app.go fires before osRun,
|
||||||
|
// when app.t is still nil, so we must re-check here.
|
||||||
|
if updater.IsUpdatePending() {
|
||||||
|
slog.Debug("update pending on startup, showing tray notification")
|
||||||
|
UpdateAvailable("")
|
||||||
|
}
|
||||||
|
|
||||||
signals := make(chan os.Signal, 1)
|
signals := make(chan os.Signal, 1)
|
||||||
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user