mirror of
https://github.com/ollama/ollama.git
synced 2026-04-17 15:53:27 +02:00
app: fix first update check delayed by 1 hour (#14427)
This commit is contained in:
@@ -35,6 +35,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
wv = &Webview{}
|
wv = &Webview{}
|
||||||
uiServerPort int
|
uiServerPort int
|
||||||
|
appStore *store.Store
|
||||||
)
|
)
|
||||||
|
|
||||||
var debug = strings.EqualFold(os.Getenv("OLLAMA_DEBUG"), "true") || os.Getenv("OLLAMA_DEBUG") == "1"
|
var debug = strings.EqualFold(os.Getenv("OLLAMA_DEBUG"), "true") || os.Getenv("OLLAMA_DEBUG") == "1"
|
||||||
@@ -208,6 +209,7 @@ func main() {
|
|||||||
uiServerPort = port
|
uiServerPort = port
|
||||||
|
|
||||||
st := &store.Store{}
|
st := &store.Store{}
|
||||||
|
appStore = st
|
||||||
|
|
||||||
// Enable CORS in development mode
|
// Enable CORS in development mode
|
||||||
if devMode {
|
if devMode {
|
||||||
@@ -360,8 +362,7 @@ func startHiddenTasks() {
|
|||||||
slog.Info("deferring pending update for fast startup")
|
slog.Info("deferring pending update for fast startup")
|
||||||
} else {
|
} else {
|
||||||
// Check if auto-update is enabled before automatically upgrading
|
// Check if auto-update is enabled before automatically upgrading
|
||||||
st := &store.Store{}
|
settings, err := appStore.Settings()
|
||||||
settings, err := st.Settings()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Warn("failed to load settings for upgrade check", "error", err)
|
slog.Warn("failed to load settings for upgrade check", "error", err)
|
||||||
} else if !settings.AutoUpdateEnabled {
|
} else if !settings.AutoUpdateEnabled {
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ func (u *Updater) TriggerImmediateCheck() {
|
|||||||
|
|
||||||
func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(string) error) {
|
func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(string) error) {
|
||||||
u.checkNow = make(chan struct{}, 1)
|
u.checkNow = make(chan struct{}, 1)
|
||||||
|
u.checkNow <- struct{}{} // Trigger first check after initial delay
|
||||||
go func() {
|
go func() {
|
||||||
// Don't blast an update message immediately after startup
|
// Don't blast an update message immediately after startup
|
||||||
time.Sleep(UpdateCheckInitialDelay)
|
time.Sleep(UpdateCheckInitialDelay)
|
||||||
@@ -333,7 +334,7 @@ func (u *Updater) StartBackgroundUpdaterChecker(ctx context.Context, cb func(str
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download successful - show tray notification (regardless of toggle state)
|
// Download successful - show tray notification
|
||||||
err = cb(resp.UpdateVersion)
|
err = cb(resp.UpdateVersion)
|
||||||
if err != nil {
|
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)
|
||||||
|
|||||||
@@ -351,10 +351,13 @@ func TestTriggerImmediateCheck(t *testing.T) {
|
|||||||
|
|
||||||
updater.StartBackgroundUpdaterChecker(ctx, cb)
|
updater.StartBackgroundUpdaterChecker(ctx, cb)
|
||||||
|
|
||||||
// Wait for goroutine to start and pass initial delay
|
// Wait for the initial check that fires after the initial delay
|
||||||
time.Sleep(10 * time.Millisecond)
|
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()
|
initialCount := checkCount.Load()
|
||||||
|
|
||||||
// Trigger immediate check
|
// Trigger immediate check
|
||||||
|
|||||||
Reference in New Issue
Block a user