Repository navigation
Conversation
Both test helpers wrote into /opt/hitpag/tmp, a path that only exists on
the machine the suite was written on. Everywhere else that directory is
absent or read-only, so the suite failed before doing any work:
FAIL: unable to create test directory: Read-only file system
CMake Error: Unable to (re)create the private pkgRedirects directory:
/opt/hitpag/tmp/cmake_ftxui_vendored_test/CMakeFiles/pkgRedirects
The C++ helper now asks the operating system for a temp directory:
TMPDIR on Termux, where neither /tmp nor /opt exists, /tmp on Linux and
%TEMP% on Windows, with the current directory as the fallback. The CMake
script takes its directory from TEST_WORK_DIR, which ctest fills in with
the project binary directory.
can_create() hardcoded the set of writable formats, which matched the p7zip 17 era. Current 7-Zip builds no longer ship SWFc, lizard, lz5, lz4 or zstd for creation, so compressing to those formats started the operation and then failed with a message that blamed the password. - can_create() keeps the candidate list but now asks the installed backend whether it can really write the format, probing each one once and caching the answer. - The probe writes a throwaway archive instead of parsing `7z i`: p7zip and 7-Zip lay that table out differently and the columns move with the locale, so the same parser produced junk on p7zip. - Only an explicit "not implemented" or "unsupported archive type" failure counts as unsupported. Any other failure stays inconclusive and is treated as supported, so a codec that merely dislikes the probe payload (SWFc needs a real SWF input) is never blocked. - error::throw_operation_failed() appends the "wrong password?" hint only when a password was supplied, so process spawn failures and unsupported formats stop sending users down the wrong path. - sevenzip_test gates its SWF case on the probed capability instead of assuming success, which keeps it green on both aarch64/p7zip 17.05 and amd64/7-Zip 26.00.
caokai674
requested changes
Sep 29, 2026
| } | ||
|
|
||
| bool run_command_to_file(const std::vector<std::string>& cmd, const std::string& path) { | ||
| std::ofstream output(path, std::ios::binary | std::ios::trunc); |
Member
There was a problem hiding this comment.
P1:这里用 std::ios::trunc 立即打开最终目标。子进程随后因损坏输入、错误密码或 codec 失败时,已有文件已经被清空/部分覆盖。请写同目录临时文件,确认 child exit=0、flush/close 成功后再原子替换目标,并覆盖已有文件保留的回归测试。
| if (file.gcount() >= 6 && header[0] == (char)0xFD && header[1] == 0x37 && header[2] == 0x7A && | ||
| header[3] == 0x58 && header[4] == 0x5A && header[5] == 0x00) { | ||
| return FileType::ARCHIVE_TAR_XZ; | ||
| return FileType::ARCHIVE_P7ZIP; |
Member
There was a problem hiding this comment.
P1:XZ magic 直接返回 ARCHIVE_P7ZIP 会让重命名或无后缀的 tar.xz 失去原来的 TAR+XZ 分派。需要区分 standalone xz 与内部为 TAR 的 xz,并加入 signature-only tar.xz 测试。
This was referenced Sep 29, 2026
Member
|
Superseded by #8, which consolidates the p7zip work, preserves current-main preview guards, fixes transactional extraction and tar.xz dispatch, adds runtime creation capability probing, and passed the integration CI. |
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.
概要
新增的归档/容器格式交给 p7zip/7-Zip 后端处理,并且在动手之前先向后端确认一次:这个格式它到底能不能写。
本分支两个提交:
Add p7zip support for additional archive and container formats— 格式分派、CLI/TUI 读取路径、文档与测试。Probe the 7-Zip backend for the formats it can actually create— 修掉can_create()里陈旧的硬编码假设。前置提交
Write test scratch data somewhere every platform provides与本仓库另一个 PR(TUI 图片预览)共用同一个提交;两个分支都基于当前的main,先合哪一个都不会冲突。为什么要探测后端
can_create()原先硬编码了一份「可写格式」清单,它对应的是 p7zip 17 时代。现在的 7-Zip 已经不再提供SWFc、lizard、lz5、lz4、zstd的写支持,于是在这些格式上 hitpag 会先开始压缩、再在半途失败,而报错信息还把原因推给密码。can_create()保留候选清单,但会先问后端该格式是否真的可写;答案缓存,每个格式只探一次。7z i:p7zip 与 7-Zip 那张表的分栏方式不同、列位置还会随 locale 移动,同一个解析器在 p7zip 上会读出垃圾数据。not implemented/unsupported archive type/unsupported method才算「不支持」,其他失败一律视为结论不确定并按支持处理。这样某个编解码器只是不接受探测用的载荷时(SWFc需要真正的 SWF 输入)不会被误判成不可用。error::throw_operation_failed()只在用户确实提供了密码时才追加「可能是密码错误」的提示;进程启动失败和不支持的格式不再把人引向错误方向。sevenzip_test的 SWF 用例改为按探测结果决定执行还是跳过,因此 aarch64/p7zip 17.05 与 amd64/7-Zip 26.00 上都能保持绿色。顺带说明:未 probe 的旧版本
sevenzip_test在 amd64 上会以E_NOTIMPL : Not implemented失败。把未 probe 的分支单独在 amd64 上重编一次,得到完全相同的失败,说明这不是本次工作引入的回归,而是那份硬编码清单的前提已经过期。验证
两个平台各自完整跑了一遍,构建目录全新,无并发。
aarch64(Android/Termux,clang,p7zip 17.05)
ctest3/3:tui_smoke_test、cmake_ftxui_vendored_test、sevenzip_testsevenzip_test输出:PASS: gz bz2 xz wim jar ova liz lz5 swfova、xz、wim、zip、lz4、zstd、liz、lz5—— 全部成功x86_64(Ubuntu 26.04,g++ 15.2.0,7-Zip 26.00)
ctest3/3:同上三个测试sevenzip_test输出:PASS: gz bz2 xz wim jar ova/SKIP optional codec: liz/SKIP optional codec: lz5/SKIP unsupported creation: swf手工创建:
ova、xz、wim、zip、lz4、zstd—— 成功;liz、lz5、swf—— 被提前拒绝,提示为:也就是说,两端的行为差异由后端能力决定,而不是平台分支。
说明
ErrorCode,OPERATION_FAILED的退出码(7)保持不变。README.md/README_zh.md。