fix(mp): stream public-account article images to disk - #132
Merged
Conversation
Owner
|
感谢贡献,麻烦修复CI问题,另外download_mp_images已经是死代码了 可以直接删除 |
Owner
|
感谢贡献 已合入 |
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.
变更说明
修复低内存设备在开启“公众号文章图片”后,下载图片较多的公众号文章时出现内存不足的问题。
原因
现有实现通过
client:get_binary将每张图片完整读入 Lua 字符串,再生成体积更大的 Base64 字符串并持续拼接到同一个 HTML 文档中。下载过程中,原始图片、Base64 副本和不断增长的 HTML 会同时驻留在 RAM;在Kobo Libra 2 等设备上容易触发 OOM。修改内容
Client:download_to_file,把公众号图片逐张流式写入文章旁的本地资源目录。mmbiz.qpic.cn和mmbiz.qlogo.cn的协议相对 URL 及 HTML 转义参数。spec/mp_article_images_spec.lua回归测试。类型
Bugfix 要求
修复前的清晰复现步骤:
Public account article images。not enough memory,文章无法正常保存或打开。预期行为:公众号文章图片能够下载和显示,图片总量不应导致 Lua RAM 随 Base64 HTML 持续增长。
实际行为:启用图片后,原始图片与 Base64/HTML 副本同时占用内存,在低内存设备上触发 OOM。
Feature 要求
不适用。本 PR 不新增 UI、菜单、弹窗或交互,只修复现有公众号图片下载路径。
测试
bash scripts/run_lua_specs.shbash scripts/check_lua_namespace.shluacheck main.lua _meta.lua weread specKOReader integration测试说明:
非公开 WeRead API
脚本路径:
复现命令与脱敏结果:
模块结构
没有新增或移动运行时模块。实现保留在现有
weread/lib/content.lua,回归测试位于spec/mp_article_images_spec.lua,符合项目命名空间约定。截图
不适用;没有 UI 或交互变更。
Checklist
settings/weread.lua、API key、cookie、token、x-wrpa-*或私人书籍内容。weread/lib/、weread/ui/命名空间规范。(未新增或移动运行时模块)weread/lib/i18n.lua。(不适用,没有新增用户可见文本)scripts/中提交可独立运行、可复现的 Python 验证脚本,并填写了复现命令和脱敏结果。(不适用,没有修改 API)