diff --git a/app/cmd/app/app.go b/app/cmd/app/app.go index 904807fd7..724c81619 100644 --- a/app/cmd/app/app.go +++ b/app/cmd/app/app.go @@ -35,6 +35,7 @@ import ( var ( wv = &Webview{} uiServerPort int + appStore *store.Store ) var debug = strings.EqualFold(os.Getenv("OLLAMA_DEBUG"), "true") || os.Getenv("OLLAMA_DEBUG") == "1" @@ -208,6 +209,7 @@ func main() { uiServerPort = port st := &store.Store{} + appStore = st // Enable CORS in development mode if devMode { @@ -360,8 +362,7 @@ func startHiddenTasks() { slog.Info("deferring pending update for fast startup") } else { // Check if auto-update is enabled before automatically upgrading - st := &store.Store{} - settings, err := st.Settings() + settings, err := appStore.Settings() if err != nil { slog.Warn("failed to load settings for upgrade check", "error", err) } else if !settings.AutoUpdateEnabled { diff --git a/app/updater/updater.go b/app/updater/updater.go index 29b6dbd3c..d2929d8a1 100644 --- a/app/updater/updater.go +++ b/app/updater/updater.go @@ -289,6 +289,7 @@ func (u *Updater) TriggerImmediateCheck() { func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(string) error) { u.checkNow = make(chan struct{}, 1) + u.checkNow <- struct{}{} // Trigger first check after initial delay go func() { // Don't blast an update message immediately after startup time.Sleep(UpdateCheckInitialDelay) @@ -333,7 +334,7 @@ func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(str continue } - // Download successful - show tray notification (regardless of toggle state) + // Download successful - show tray notification err = cb(resp.UpdateVersion) if err != nil { slog.Warn("failed to register update available with tray", "error", err) diff --git a/app/updater/updater_test.go b/app/updater/updater_test.go index c6857edbe..ae8292ebf 100644 --- a/app/updater/updater_test.go +++ b/app/updater/updater_test.go @@ -351,10 +351,13 @@ func TestTriggerImmediateCheck(t *testing.T) { updater.StartBackgroundUpdaterChecker(ctx, cb) - // Wait for goroutine to start and pass initial delay - time.Sleep(10 * time.Millisecond) + // Wait for the initial check that fires after the initial delay + select { + case <-checkDone: + case <-time.After(2 * time.Second): + t.Fatal("initial check did not happen") + } - // With 1 hour interval, no check should have happened yet initialCount := checkCount.Load() // Trigger immediate check