fix: 修复视频分析并发处理和数据库存储问题

🔧 修复视频分析模块的关键并发和存储问题

**主要修复:**
1. **并发竞争条件修复**
   - 解决相同视频hash同时处理导致重复分析的问题
   - 重构并发控制机制,使用per-video独立锁和事件
   - 消除30秒超时后多个请求同时执行的竞争条件

2. **数据库存储优化**
   - 移除Videos表path字段的复杂唯一性检查逻辑
   - 简化为基于hash的纯唯一标识存储
   - 修复path字段重复导致的IntegrityError

3. **代码简化和清理**
   - 删除重编码视频检测功能(复杂且用处有限)
   - 移除不必要的特征匹配和计数更新逻辑
   - 简化存储路径生成,统一使用hash前缀

Fixes: 视频并发处理竞争条件、数据库存储冲突、聊天循环变量错误
This commit is contained in:
雅诺狐
2025-08-22 23:55:54 +08:00
committed by Windpicker-owo
parent c324357aa7
commit e39c34f366
10 changed files with 279 additions and 623 deletions

View File

@@ -174,6 +174,9 @@ class CycleProcessor:
- 在FOCUS模式下同步生成确保及时响应
- 发送生成的回复并结束循环
"""
# 初始化reply_to_str以避免UnboundLocalError
reply_to_str = None
if self.context.loop_mode == ChatMode.NORMAL:
if not gen_task:
reply_to_str = await self._build_reply_to_str(message_data)
@@ -185,6 +188,11 @@ class CycleProcessor:
request_type="chat.replyer.normal",
)
)
else:
# 如果gen_task已存在但reply_to_str还未构建需要构建它
if reply_to_str is None:
reply_to_str = await self._build_reply_to_str(message_data)
try:
response_set = await asyncio.wait_for(gen_task, timeout=global_config.chat.thinking_timeout)
except asyncio.TimeoutError: