feat: use system curl for cmhub image downloads
This commit is contained in:
@@ -1491,3 +1491,12 @@
|
||||
- 测试:`tests/test_appconfig.py` 覆盖旧配置超限值会归一到 1/5/10、正常值不变;`tests/test_gui.py` 覆盖三个 spin 的新范围。
|
||||
- 文档:`docs/06-tasks.md` 将 T-547 标为 DONE;同步 `docs/04-architecture.md`、`docs/api.md`、`docs/routes.md` 和 `docs/current-state.md`。
|
||||
- 验证:`py -3.10 -m unittest discover -s tests -p "test_appconfig.py"` 通过(15 tests);`py -3.10 -m unittest discover -s tests -p "test_gui.py"` 通过(102 tests);`python -m ruff check app tests main.py` 通过;`py -3.10 -m compileall app main.py` 通过;`git diff --check` 通过;`py -3.10 -m unittest discover -s tests` 通过(244 tests)。
|
||||
|
||||
## 【2026-07-08】T-548 · cmhub 图片下载优先系统 curl
|
||||
|
||||
- 需求:cmhub 生图拿到 `image_url` 后,图片下载可优先使用 Windows 10+ 系统自带 curl,贴近用户用 curl 实测较快的下载路径;不得捆绑 `wget/` 或其它下载二进制。
|
||||
- 代码:`app/appconfig.py` 新增 `ai.cmhub.download_with_curl`,默认 `auto`,并归一为 `auto/true/false`;`app/ai.py` 只替换 `image_url` 下载后端,生成、models、balance 仍走共享 requests Session。`auto` 在 Windows 且检测到系统 curl 时优先 curl,非 Windows、无 curl 或 curl 执行失败时自动回退 requests。
|
||||
- 安全:curl 调用前仍执行 `_assert_public_http_url()`,避免 SSRF 绕过;用 `subprocess.run([...], shell=False)`;带 token 的 `image_url` 写入临时 curl 配置文件并通过 `-K` 传入,不出现在命令行参数;`use_system_proxy=false` 时追加 `--noproxy "*"`;下载后仍走现有 JPEG 重编码和大小上限。
|
||||
- 测试:`tests/test_ai.py` 覆盖 curl 参数、URL 不进 argv、SSRF 校验先于 subprocess、curl 失败回退 requests、无 curl 自动回退 requests;现有 cmhub 测试 helper 显式关闭 curl,避免单测误连真实网络。`tests/test_appconfig.py` 覆盖 `download_with_curl` 默认值和归一。
|
||||
- 文档:同步 `docs/06-tasks.md`、`docs/04-architecture.md`、`docs/api.md`、`docs/cmhub-integration-design.md`、`docs/packaging.md` 和 `docs/current-state.md`。
|
||||
- 验证:`py -3.10 -m unittest discover -s tests -p "test_ai.py"` 通过(38 tests);`py -3.10 -m unittest discover -s tests -p "test_appconfig.py"` 通过(16 tests);`python -m ruff check app tests main.py` 通过;`py -3.10 -m compileall app main.py` 通过;`git diff --check` 通过;`py -3.10 -m unittest discover -s tests` 通过(250 tests)。
|
||||
|
||||
Reference in New Issue
Block a user