Skip to content

feat: add validation for combined stream sizes and improve error hand…#2

Open
Minlor wants to merge 1 commit intomasterfrom
wuwa
Open

feat: add validation for combined stream sizes and improve error hand…#2
Minlor wants to merge 1 commit intomasterfrom
wuwa

Conversation

@Minlor
Copy link
Member

@Minlor Minlor commented Feb 23, 2026

This pull request improves robustness and compatibility in the patch_krdir.rs module by adding stricter validation, handling optional fields, and refactoring code to reduce duplication. The changes focus on error handling, compression mode support, and streamlining decompression logic.

Validation and error handling improvements:

  • Added checks to ensure the combined old and new file sizes match expected values, returning descriptive errors if mismatched in impl KrPatchDir.
  • Enforced that only Zstd compression mode is supported for both HDIFF19 and HDIFF13 formats, with clear error messages for unsupported modes in parse_hd19 and parse_hd13. [1] [2]
  • Added validation to ensure decompressed block sizes match expectations in the new read_block_maybe_zstd function.

Compatibility and parsing enhancements:

  • Improved parsing of optional extra VarInt fields in KrDiff variants, only consuming them if enough bytes remain, to handle different file formats more gracefully in parse_hd19_head.
  • Updated patch application logic to ensure write callbacks are correctly invoked after copying remaining bytes, improving progress tracking in apply_patch.

Code refactoring:

  • Introduced the read_block_maybe_zstd helper function to unify decompression logic and reduce code duplication in block reading for covers and headers. [1] [2] [3]…ling in patch processing

@TukanDev TukanDev self-assigned this Feb 23, 2026
@TukanDev
Copy link
Member

Even if this is mostly some code organization and checks i will hold this one off until current master is tested properly as knowing how cursed this shitty format alone is... i dont wanna leave any chances

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