feat: add concurrency safety, caption detection, admin enhancements, and performance improvements

This commit is contained in:
2026-06-14 22:20:02 +08:00
parent 8f13c31991
commit 29fb20828e
23 changed files with 1782 additions and 114 deletions
+20
View File
@@ -24,6 +24,26 @@ from app.models import (
from app.utils import utc_now
# ── ChromaDB 隔离(autouse,所有测试)──────────────────────────────────
@pytest.fixture(autouse=True)
def _isolate_chroma(monkeypatch, tmp_path):
"""所有测试把 ChromaDB 隔离到临时目录 + 重置单例,绝不污染 data/chroma。
与内存 DB 隔离同理:summarize 后处理经真实 _maybe_index_chroma → index_paper
写入,不隔离会把测试夹具(2401.*)泄漏到生产 data/chroma,污染语义搜索。
每个测试前重置 _chroma 单例,确保 CHROMA_DIR 指向本次 tmp。
"""
import app.services.embedder as emb
from app.config import settings
monkeypatch.setattr(settings, "CHROMA_DIR", str(tmp_path / "chroma"))
emb._chroma.reset()
yield
emb._chroma.reset()
# ── 内存数据库 ──────────────────────────────────────────────────────────