feat(updater): update StartModelsUpdater to block until models refresh completes

This commit is contained in:
hkfires
2026-03-10 14:41:58 +08:00
parent efbe36d1d4
commit e333fbea3d

View File

@@ -42,12 +42,13 @@ func init() {
} }
} }
// StartModelsUpdater starts a one-time models refresh on startup. // StartModelsUpdater runs a one-time models refresh on startup.
// It attempts to fetch models from network once, then exits. // It blocks until the startup fetch attempt finishes so service initialization
// Safe to call multiple times; only one updater will be started. // can wait for the refreshed catalog before registering auth-backed models.
// Safe to call multiple times; only one refresh will run.
func StartModelsUpdater(ctx context.Context) { func StartModelsUpdater(ctx context.Context) {
updaterOnce.Do(func() { updaterOnce.Do(func() {
go runModelsUpdater(ctx) runModelsUpdater(ctx)
}) })
} }