Skip to content

Add Bandizip fallback for archive extraction - #4

Merged
uyujkk merged 2 commits into
uyujkk:mainfrom
CaramelizedCUDA:feat/bandizip-extraction
Sep 29, 2026
Merged

uyujkk merged 2 commits into
uyujkk:mainfrom
CaramelizedCUDA:feat/bandizip-extraction

Conversation

@CaramelizedCUDA

@CaramelizedCUDA CaramelizedCUDA commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

修改内容 / Summary

When 7-Zip is not installed or bundled, downloaded RAR/7Z/ZIPX/CAB files currently fail to extract even if Bandizip is installed. Add an automatic fallback to Bandizip's console tool (bz.exe) for both online downloads and local archive imports, preserving 7-Zip priority and the existing ZIP/TAR extraction engines. Bound tar/bz execution so stalled tools cannot leave the task waiting indefinitely.

未安装或附带 7-Zip 时,新增对 Bandizip 控制台工具 bz.exe 的自动发现与备用解压支持。在线下载和本地导入共用此流程;检查与解压使用同一份锁定的临时快照,并为 tar/bz 增加超时处理。

用户可见变化 / User-visible Changes

  • Find bz.exe through application folders, registered Bandizip installations (including custom drives), standard installation directories, and PATH. No Bandizip binaries or new package dependencies are added.
  • Pass arguments without shell quoting, support Unicode/space-containing paths, and close stdin so password prompts cannot wait for interactive input.
  • Copy the Bandizip input into a unique temporary directory. Lock the source while copying and hold the snapshot open for read sharing only throughout RAR5 validation, both tar listings and bz extraction. Clean up on success/failure; preserve the original error if cleanup also fails.
  • Inspect paths and links with Windows tar.exe before extraction. Add bounded RAR5 header validation because libarchive omits junction/file-copy redirections from its listing. Detect RAR5 hard-link annotations even when tar prints regular-file permissions.
  • Stop when inspection is unsupported. RAR5 quick-open cached headers, split/multivolume archives, encrypted headers, unsupported/malformed header layouts, excessive metadata, and executable SFX archives require the existing 7-Zip path. Never retry failed 7-Zip validation/extraction with Bandizip.
  • Limit each tar/bz invocation to 10 minutes, including reading stdout/stderr concurrently. On timeout, attempt process-tree termination and bound the cleanup wait. This also applies to the existing TAR path. If the parent has already exited but a descendant holds a pipe, report that descendant termination cannot be confirmed while still ending the wait. 7-Zip execution is unchanged.
  • Update Chinese and English error text and usage documentation, including temporary-space requirements and timeout behavior.

The RAR5 guard follows the official format description; command arguments follow Bandizip's documented interface.

验证 / Verification

  • Ran the complete scripts/test-all.ps1: 254 tests passed (220 Core + 7 DataStore + 27 Updater), all three coverage gates passed, WinUI x64 build passed with zero warnings/errors, and the minimal release ZIP contract passed.
  • Added 93 tests across executable discovery, command construction, failure paths, traversal/link rejection, bounded RAR5 validation, snapshot consistency/cleanup, and real-process timeout/output handling.
  • Checked paired Chinese/English strings and documentation.
  • The change contains no user configuration, caches, logs, credentials, build outputs, user mods, or third-party binaries.

WinUI acceptance on the final build, using an isolated release copy/new library with Bandizip 7.38.0.1 (7.38 Beta x64), Windows bsdtar/libarchive 3.7.7, and no available 7-Zip:

  • Local import through Import Mod and the native file picker: generated gui-local-import.7z, imported GuiLocalMod, both files matched source SHA-256 hashes.
  • Online download through the GameBanana list, download-file selection and destination dialog: Tomb Raider Fluorite V3, fluorite_croft_v3_nocrossib.7z (16,562,923 bytes). UI reported successful download/extraction; all 95 archive files matched independent Windows tar extraction by SHA-256.
  • Both tests used .7z to exercise the Bandizip fallback. The existing installation, game and user library were not used.

Earlier actual-tool validation on the initial PR commit passed 15 checks with the same tool versions: 7Z/ZIPX Unicode/space/nested paths and SHA-256 comparisons, CAB, stored/compressed RAR5, rejection of links/traversal/corruption, and noninteractive encrypted-archive failure. RAR fixtures came from libarchive's tests; junction/copy-link variants used corrected header CRCs. The compiled WinUI discovery methods found Bandizip on a custom drive with no 7-Zip available.

Local build used .NET 8.0.425 and existing Visual Studio MSBuild, with Microsoft build components supplied through process-local paths. No project dependency or build-script changes were needed.

Not verified: in-game behavior/deployment, other Bandizip versions, and other Windows tar versions. The GUI tests covered successful imports/downloads; timeout behavior was verified separately with automated real-process tests using shorter deadlines.

相关 Issue / Related Issue

No existing Bandizip issue or open pull request was found when preparing this change.

@uyujkk

uyujkk commented Sep 29, 2026

Copy link
Copy Markdown
Owner

感谢提交这个改进!CI 已通过,解压工具的选择逻辑和新增测试我也看过了。

合并前想请你再确认三点:

  1. 能否在实际安装了 Bandizip、且测试副本中没有 7-Zip 的环境下,分别验证一次 WinUI 的在线下载和本地压缩包导入?请注明 Bandizip 版本及测试结果。
  2. 预检查与 bz.exe 解压会分别读取压缩包路径。是否可以使用一份固定的暂存文件,避免两步之间源文件发生变化?
  3. 对 tar.exe 和 bz.exe,是否可以增加超时或取消机制,避免异常压缩包使任务一直等待?

后两点是代码审查中发现的潜在边界,并非已经复现的问题。如果你认为当前实现已有足够保护,也欢迎说明。谢谢!


Thanks for the contribution! CI has passed, and I’ve reviewed the tool-selection logic and added tests.

Before merging, could you please confirm:

  1. A real WinUI test of both online download and local archive import with Bandizip installed and 7-Zip absent from an isolated test copy, including the Bandizip version and results.
  2. Whether preflight inspection and bz.exe extraction can use the same immutable staged archive, so the source cannot change between the two steps.
  3. Whether tar.exe and bz.exe can have a timeout or cancellation path to avoid waiting indefinitely on an abnormal archive.

The last two are potential review concerns, not reproduced bugs. If the current implementation already addresses them, an explanation would also be helpful. Thank you!

@uyujkk
uyujkk requested review from uyujkk and removed request for uyujkk September 29, 2026 06:34
@CaramelizedCUDA

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed the three points in 154d99f and completed both WinUI checks on that build.

  1. Real WinUI acceptance: tested an isolated release copy and a new test library on Windows x64, with Bandizip 7.38.0.1 (7.38 Beta x64) and Windows bsdtar/libarchive 3.7.7. No bundled or system 7-Zip was available at any location checked by the app.

    • Local import: used Import Mod and the native file picker to import a generated gui-local-import.7z. GuiLocalMod appeared in the selected category; both extracted files matched the source SHA-256 hashes.
    • Online download: used the WinUI GameBanana list, file selection and download-location dialog for Tomb Raider Fluorite V3, selecting fluorite_croft_v3_nocrossib.7z (16,562,923 bytes). The UI reported successful download and extraction. All 95 archive files matched an independent Windows tar extraction by SHA-256. The downloaded archive SHA-256 was 756BAAA2AF060C2B4C1338AE336B989956FB0351943570E4479832F61171C65F.
    • Both paths used .7z to exercise the Bandizip fallback. The existing installation, game and user mod library were not used. No game/deployment acceptance or other Bandizip/tar versions are claimed.
  2. Fixed input: the Bandizip path copies the source into a unique temporary directory while holding the source open for read sharing only. It then holds the staged archive open with the same sharing restriction throughout RAR5 validation, both tar listings and bz extraction. All stages receive the same snapshot path. Tests mutate the original after inspection starts, verify unchanged staged bytes, and check that staged writes/deletion are denied on Windows. Cleanup runs on success and failure; a cleanup failure is attached without masking the original timeout/error.

  3. Bounded tool execution: every tar/bz invocation now has a 10-minute limit, covering process exit and both output streams. Output is drained concurrently and stdin is closed. On timeout the runner attempts process-tree termination with a bounded cleanup wait. If the parent has already exited but a descendant keeps a pipe open, the wait still ends and the error explicitly says descendant termination could not be confirmed. The existing TAR path uses the same runner; 7-Zip execution is unchanged.

Full scripts/test-all.ps1 passed: 254 tests (220 Core + 7 DataStore + 27 Updater), all coverage gates, WinUI x64 build with zero warnings/errors, and release-package verification. The 12 additional tests cover snapshot consistency/cleanup, each timed-out extraction stage, large concurrent stdout/stderr, termination of a real process and its child, inherited pipes after parent exit, and invalid deadlines. Chinese/English messages and user guides are updated.

The Actions run for this new commit currently reports action_required, so the remote checks still need maintainer approval; the local results above are complete.

@uyujkk
uyujkk merged commit e44d347 into uyujkk:main Sep 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants