修复:CI 部署环境与 ref 错配、迁移碎片化、图片意图 source_span、章节物化脏版式、会话历史与本地语音不一致

新增:TTS 上传 COS 与分片、章节 reading_segments 物化与快照、markdown 清洗、会话消息 repository、语音 store 重构与相关测试
This commit is contained in:
Kevin
2026-03-20 16:36:42 +08:00
parent 7317bf10cd
commit 8af37e5e8e
65 changed files with 1704 additions and 504 deletions

View File

@@ -3,6 +3,10 @@
from sqlalchemy import delete, select
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.cos_url_keys import (
collect_cos_keys_from_tts_url_list,
extract_cos_object_key_if_owned,
)
from app.features.asset.models import Asset
from app.features.auth.models import RefreshToken
from app.features.conversation.models import Conversation, Segment
@@ -96,6 +100,19 @@ async def collect_object_storage_keys_before_purge(
)
keys.update(x for x in r3.scalars().all() if x)
seg_rows = await db.execute(
select(Segment.audio_url, Segment.tts_audio_urls)
.join(Conversation, Segment.conversation_id == Conversation.id)
.where(Conversation.user_id == user_id)
)
for audio_url, tts_urls in seg_rows.all():
k = extract_cos_object_key_if_owned(audio_url)
if k:
keys.add(k)
keys |= collect_cos_keys_from_tts_url_list(
tts_urls if isinstance(tts_urls, list) else None
)
return sorted(keys)