perf(media): 缩略图优化、测试覆盖与手机地图修复 - #175
Merged
Merged
Conversation
Owner
Author
|
I have read and agree to the CLA |
- validate_filename 的 Windows 专属非法名(a<b / name. / CON)拆出独立用例, 在 patch os.name='nt' 下断言(同 60798f6 的跨平台做法) - compute_relative_path / compute_browse_path / get_user_roots / build_folder_list 放弃 C:/ 盘符字面量,改用 _normalize() 归一化的 临时目录路径(同 test_path_utils.py 的既有约定) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
描述
本 PR 包含两组改动:
1. 缩略图性能优化(#173)
/api/medias/{photo_id}/thumbnail原先每次请求都要打开 DB 会话查Photo记录来定位用户存储根。虚拟列表快速滚动时会瞬间产生上百个短生命周期请求,DB 开销全部花在拿 owner 存储路径上。 后端: - 新增 owner 前缀确定性路由/api/medias/{owner_id}/{photo_id}/thumbnail:全程不打开 DB 会话,仅靠文件系统操作解析路径,保留路径穿越校验,返回Cache-Control: immutable- API 启动时(lifespan)通过warm_storage_base_cache()预热全部用户的 storage base 到内存 - 旧路由保留做向后兼容(老客户端、已保存头像、Agent 历史消息) - 新增app/service/media_urls.py统一 URL 构造器,年度报告 / 相似照片 / 主动回忆 / Agent 提示词全部切换 -Photo响应 schema 新增owner_id字段 前端: - 新增src/utils/mediaUrl.ts(thumbnailUrl/thumbnailPath/thumbnailToFileUrl/photoIdFromMediaUrl),全站 20+ 处手拼 URL 统一收口;owner 优先取数据owner_id,回退 localStorage 当前用户 -PhotoGallery/FlatPhotoGallery移除「fetch 探测 + img 二次请求」双重加载,直接赋值<img>(原探测不消费 body,导致每张图请求两次) - AgentChat 的 URL 解析兼容新旧两种格式 CLI: -trailsnap medias get同步使用 owner 前缀端点 ### 2. 夜间测试覆盖补充(#174) 为覆盖率扫描发现的未触达分支补测试: - AI 服务runtime_limits.py:优先级降低的 Windows/POSIX 分支、线程预算钳制 - 后端path_validation.py/filename.py/path.py:非法文件名、超长路径、uuid/hash 识别、get_user_roots回退 - 后端location.pyscene CRUD 404/403 分支;face.pyadd_photos_to_identity全分支 - 前端MobileBackup/MobileBackupSettings两个从未被 e2e 引用的 view 的 web 兜底分支3. 手机 App 天地图瓦片修复(#176)
/tianditu-tiles/Nginx 代理变更类型
相关 Issue Closes #173 Closes #174 Closes #176
如何测试
已在本地完整验证(dev 模式跑通缩略图加载、年度报告、Agent 聊天、相似照片等场景),CI 由 GitHub Actions 负责。新增配套单元测试: -
test_media_api.py:owner 前缀路由返回文件与 400 校验 -test_user_storage.py:warm_storage_base_cache预热 -test_agent_memory.py/test_proactive_memory.py/test_similar_photo_service.py:URL 格式更新 - CLItest_cli_commands.py:owner 端点构造检查清单
🤖 Generated with Claude Code