Merge branch 'xilu0/main'

This commit is contained in:
shaw
2025-11-27 20:41:37 +08:00
2 changed files with 7 additions and 4 deletions

View File

@@ -212,6 +212,8 @@ class ApiKeyService {
const keyData = await redis.findApiKeyByHash(hashedKey)
if (!keyData) {
// ⚠️ 警告:映射表查找失败,可能是竞态条件或映射表损坏
logger.warn(`⚠️ API key not found in hash map: ${hashedKey.substring(0, 16)}... (possible race condition or corrupted hash map)`)
return { valid: false, error: 'API key not found' }
}
@@ -714,10 +716,11 @@ class ApiKeyService {
updatedData.updatedAt = new Date().toISOString()
// 更新时不需要重新建立哈希映射因为API Key本身没有变化
await redis.setApiKey(keyId, updatedData)
// 传递hashedKey以确保映射表一致性
// keyData.apiKey 存储的就是 hashedKey见generateApiKey第123行
await redis.setApiKey(keyId, updatedData, keyData.apiKey)
logger.success(`📝 Updated API key: ${keyId}`)
logger.success(`📝 Updated API key: ${keyId}, hashMap updated`)
return { success: true }
} catch (error) {