From efbe36d1d4d0830486f29fe35092a917f5b9326f Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:18:54 +0800 Subject: [PATCH] feat(updater): change models refresh to one-time fetch on startup --- internal/registry/model_updater.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/internal/registry/model_updater.go b/internal/registry/model_updater.go index 1aa54845..f0517df6 100644 --- a/internal/registry/model_updater.go +++ b/internal/registry/model_updater.go @@ -15,8 +15,7 @@ import ( ) const ( - modelsFetchTimeout = 30 * time.Second - modelsRefreshInterval = 3 * time.Hour + modelsFetchTimeout = 30 * time.Second ) var modelsURLs = []string{ @@ -43,8 +42,8 @@ func init() { } } -// StartModelsUpdater starts the background models refresh goroutine. -// It immediately attempts to fetch models from network, then refreshes every 3 hours. +// StartModelsUpdater starts a one-time models refresh on startup. +// It attempts to fetch models from network once, then exits. // Safe to call multiple times; only one updater will be started. func StartModelsUpdater(ctx context.Context) { updaterOnce.Do(func() { @@ -53,20 +52,9 @@ func StartModelsUpdater(ctx context.Context) { } func runModelsUpdater(ctx context.Context) { - // Immediately try network fetch once + // Try network fetch once on startup, then stop. + // Periodic refresh is disabled - models are only refreshed at startup. tryRefreshModels(ctx) - - ticker := time.NewTicker(modelsRefreshInterval) - defer ticker.Stop() - - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - tryRefreshModels(ctx) - } - } } func tryRefreshModels(ctx context.Context) {