修正getAllUsers(),修正启动时自动迁移执行多次

This commit is contained in:
mtvpls
2025-12-24 23:43:28 +08:00
parent c7b9097447
commit e26c412c47
3 changed files with 71 additions and 60 deletions
+6 -7
View File
@@ -645,13 +645,12 @@ export abstract class BaseRedisStorage implements IStorage {
// ---------- 获取全部用户 ----------
async getAllUsers(): Promise<string[]> {
const keys = await this.withRetry(() => this.client.keys('u:*:pwd'));
return keys
.map((k) => {
const match = k.match(/^u:(.+?):pwd$/);
return match ? ensureString(match[1]) : undefined;
})
.filter((u): u is string => typeof u === 'string');
// 从新版用户列表获取
const userListKey = this.userListKey();
const users = await this.withRetry(() =>
this.client.zRange(userListKey, 0, -1)
);
return users.map(u => ensureString(u));
}
// ---------- 管理员配置 ----------