Expand description
Post-apply integrity verification against caller-supplied file hashes.
Post-apply integrity check for files produced by either the sequential
apply_patch driver or the indexed
IndexApplier::execute driver.
The per-chunk CRC32 the parser already enforces catches transit corruption
of the patch stream itself, but it cannot detect silent corruption of the
resulting SqPack files on disk. Square Enix’s patch lists carry SHA1
hashes for the post-apply .index / .dat files (whole-file or split into
fixed-size blocks); HashVerifier reads those files back from disk and
compares against caller-supplied expected hashes.
This is a separate verification step the caller invokes after
apply_patch or
IndexApplier::execute returns
Ok. The library never bakes hash verification into the apply loop —
parsing the SE patch list to build the expected-hash input is the
consumer’s responsibility (in practice, gaveloc-patcher).
§Modes
- Whole-file (
ExpectedHash::Whole) — single hash over the entire file. Cheap to express; an opaque single failure for multi-GiB files. - Block-mode (
ExpectedHash::Blocks) — file is split into fixed-size blocks (the SE patch list uses 50 MiB); one hash per block. Pinpoints which block is bad, so a user-facing repair flow can re-fetch a narrow range rather than the whole file.
Only SHA-1 is supported — it is what Square Enix’s patch list carries. Should the format ever ship another algorithm, a new enum can wrap the current shape as an additive change.
§Example
use zipatch_rs::verify::{ExpectedHash, HashVerifier, Sha1Digest};
let report = HashVerifier::new()
.expect(
"/opt/ffxiv/game/sqpack/ffxiv/000000.win32.index",
ExpectedHash::whole(Sha1Digest::new([0u8; 20])),
)
.execute()
.unwrap();
if !report.is_clean() {
for (path, outcome) in report.failures() {
eprintln!("{}: {outcome:?}", path.display());
}
}Structs§
- Hash
Verifier - Build up a set of
(path, expected_hash)pairs, thenSelf::executeto hash the on-disk files and compare against the expected values. - Hash
Verify Report - Structured outcome of a
HashVerifier::executerun. - Parse
Sha1 Digest Error - Error returned when
Sha1Digest::from_stris given a malformed input. - Sha1
Digest - A 20-byte SHA-1 digest.
Enums§
- Expected
Hash - Expected hash spec for a single file.
- File
Verify Outcome - Per-file outcome of a
HashVerifier::executerun.