fix(leonardo): cookie 写回改 CAS,并补上额度对账后的轮换写回
Leonardo 只认加密的 session_data 缓存,轮换值一旦没存住账号就会被判死。写回原先是无条件 update:长任务(生成、慢额度查询)手里的旧 cookie 完成时会盖掉期间 keepalive 存好的新值。改为 SwapValue(WHERE value = 旧值 才写),旧值无法覆盖新值;reconcileLeonardoCredits 原先完全没写回 FetchCreditsBalance 带回的轮换值,补上。
This commit is contained in:
@@ -195,10 +195,10 @@ func (s *TokenService) RefreshLeonardoSessions(ctx context.Context) {
|
||||
}
|
||||
continue // leave the stamp alone so the next tick retries
|
||||
}
|
||||
fields := map[string]any{}
|
||||
if fresh, ok := s.leonardo.RotatedCookie(a.Value); ok && strings.TrimSpace(fresh) != "" {
|
||||
fields["value"] = fresh
|
||||
_, _ = s.tokens.SwapValue(callCtx, "leonardo", a.ID, a.Value, fresh)
|
||||
}
|
||||
fields := map[string]any{}
|
||||
meta := cloneJSONMap(a.Meta)
|
||||
meta[leonardoKeptAtKey] = int(time.Now().Unix())
|
||||
fields["meta"] = meta
|
||||
@@ -459,7 +459,7 @@ func (s *TokenService) persistLeonardoCookie(ctx context.Context, tokenID, cooki
|
||||
return
|
||||
}
|
||||
if fresh, ok := s.leonardo.RotatedCookie(cookie); ok && strings.TrimSpace(fresh) != "" {
|
||||
_, _ = s.tokens.Update(ctx, "leonardo", tokenID, map[string]any{"value": fresh})
|
||||
_, _ = s.tokens.SwapValue(ctx, "leonardo", tokenID, cookie, fresh)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user