improvement(chat): 增强 realtime 增量同步并补充消息搜索索引接口

- 新增后台 autosync:监听 db_storage 变化后触发 realtime -> decrypted 增量同步(去抖/限频)\n- 优化 WCDB realtime 关闭:支持锁超时,避免 busy 时强行 shutdown\n- 新增消息搜索索引相关接口(status/build/senders)\n- 前端关闭 realtime 前改为 sync_all,减少切回解密库后的列表/消息落后\n- 增加解密库消息表/索引创建相关单测
This commit is contained in:
2977094657
2026-02-03 16:31:31 +08:00
parent 625526ff3b
commit 3297f24f52
7 changed files with 975 additions and 71 deletions

View File

@@ -615,16 +615,36 @@ class WCDBRealtimeManager:
except Exception:
pass
def close_all(self) -> None:
def close_all(self, *, lock_timeout_s: float | None = None) -> bool:
"""Close all known WCDB realtime connections.
When `lock_timeout_s` is None, this waits indefinitely for per-connection locks.
When provided, this will skip busy connections after the timeout and return False.
"""
with self._mu:
conns = list(self._conns.values())
self._conns.clear()
ok = True
for conn in conns:
try:
with conn.lock:
if lock_timeout_s is None:
with conn.lock:
close_account(conn.handle)
continue
acquired = conn.lock.acquire(timeout=float(lock_timeout_s))
if not acquired:
ok = False
logger.warning("[wcdb] close_all skip busy conn account=%s", conn.account)
continue
try:
close_account(conn.handle)
finally:
conn.lock.release()
except Exception:
ok = False
continue
return ok
WCDB_REALTIME = WCDBRealtimeManager()