mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
feat(watcher): ensure reload callback triggers before auth refresh
- Moved `w.reloadCallback(cfg)` invocation to occur before `refreshAuthState()` for proper configuration updates.
This commit is contained in:
@@ -553,6 +553,12 @@ func (w *Watcher) reloadClients() {
|
|||||||
|
|
||||||
totalNewClients := authFileCount + glAPIKeyCount + claudeAPIKeyCount + codexAPIKeyCount + openAICompatCount
|
totalNewClients := authFileCount + glAPIKeyCount + claudeAPIKeyCount + codexAPIKeyCount + openAICompatCount
|
||||||
|
|
||||||
|
// Ensure consumers observe the new configuration before auth updates dispatch.
|
||||||
|
if w.reloadCallback != nil {
|
||||||
|
log.Debugf("triggering server update callback before auth refresh")
|
||||||
|
w.reloadCallback(cfg)
|
||||||
|
}
|
||||||
|
|
||||||
w.refreshAuthState()
|
w.refreshAuthState()
|
||||||
|
|
||||||
log.Infof("full client reload complete - old: %d clients, new: %d clients (%d auth files + %d GL API keys + %d Claude API keys + %d Codex keys + %d OpenAI-compat)",
|
log.Infof("full client reload complete - old: %d clients, new: %d clients (%d auth files + %d GL API keys + %d Claude API keys + %d Codex keys + %d OpenAI-compat)",
|
||||||
@@ -564,12 +570,6 @@ func (w *Watcher) reloadClients() {
|
|||||||
codexAPIKeyCount,
|
codexAPIKeyCount,
|
||||||
openAICompatCount,
|
openAICompatCount,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Trigger the callback to update the server
|
|
||||||
if w.reloadCallback != nil {
|
|
||||||
log.Debugf("triggering server update callback")
|
|
||||||
w.reloadCallback(cfg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// createClientFromFile creates a single client instance from a given token file path.
|
// createClientFromFile creates a single client instance from a given token file path.
|
||||||
|
|||||||
Reference in New Issue
Block a user