Skip to content

Commit 3a20605

Browse files
AusAgentSmithAusAgentSmith
authored andcommitted
v0.1.1: fix backwards compat for repair_from_verify API
Restore the 3-arg repair_from_verify(file_set, dir, verify_result) signature for backwards compatibility with existing consumers. The re_verify parameter (added in git but not in crates.io 0.1.0) is now available via repair_from_verify_no_reverify() instead. Also includes the MSVC build fix from 3886064 (target-conditional md5-asm to avoid GNU assembly on Windows MSVC).
1 parent fa0150f commit 3a20605

5 files changed

Lines changed: 29 additions & 11 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-par2"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55
description = "Pure Rust PAR2 verify and repair with SIMD-accelerated Galois field arithmetic"
66
license = "MIT OR Apache-2.0"

‎src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub mod types;
3737
mod verify;
3838

3939
pub use packets::{ParseError, parse_par2_file as parse, parse_par2_reader};
40-
pub use repair::{RepairError, RepairResult, repair, repair_from_verify};
40+
pub use repair::{RepairError, RepairResult, repair, repair_from_verify, repair_from_verify_no_reverify};
4141
pub use types::{
4242
DamagedFile, Md5Hash, MissingFile, Par2File, Par2FileSet, SliceChecksum, VerifiedFile,
4343
VerifyResult,

‎src/repair.rs‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub enum RepairError {
7878
/// [`repair_from_verify`] instead to skip the redundant verification pass.
7979
pub fn repair(file_set: &Par2FileSet, dir: &Path) -> Result<RepairResult, RepairError> {
8080
let verify_result = verify::verify(file_set, dir);
81-
repair_from_verify(file_set, dir, &verify_result, true)
81+
repair_from_verify_inner(file_set, dir, &verify_result, true)
8282
}
8383

8484
/// Repair using a pre-computed [`VerifyResult`].
@@ -93,17 +93,35 @@ pub fn repair(file_set: &Par2FileSet, dir: &Path) -> Result<RepairResult, Repair
9393
/// matrix inversion from O(N²D) to O(D³), which is the difference between
9494
/// minutes and milliseconds for typical repair scenarios.
9595
///
96-
/// When `re_verify` is true, a full MD5 verification pass runs after repair
97-
/// to confirm all files are correct. When false, the repair result is trusted
98-
/// (the Reed-Solomon math is deterministic — if the matrix inverted and I/O
99-
/// succeeded, the output is correct). Skipping re-verify saves a full read
100-
/// of all files (~6s per 5GB).
96+
/// After repair, a full MD5 verification pass confirms all files are correct.
97+
/// To skip re-verification, use [`repair_from_verify_no_reverify`].
10198
///
10299
/// This is a blocking operation. For async contexts, wrap in `spawn_blocking`.
103100
pub fn repair_from_verify(
104101
file_set: &Par2FileSet,
105102
dir: &Path,
106103
verify_result: &VerifyResult,
104+
) -> Result<RepairResult, RepairError> {
105+
repair_from_verify_inner(file_set, dir, verify_result, true)
106+
}
107+
108+
/// Like [`repair_from_verify`], but skips re-verification after repair.
109+
///
110+
/// The Reed-Solomon math is deterministic — if the matrix inverted and I/O
111+
/// succeeded, the output is correct. Skipping re-verify saves a full read
112+
/// of all files (~6s per 5GB).
113+
pub fn repair_from_verify_no_reverify(
114+
file_set: &Par2FileSet,
115+
dir: &Path,
116+
verify_result: &VerifyResult,
117+
) -> Result<RepairResult, RepairError> {
118+
repair_from_verify_inner(file_set, dir, verify_result, false)
119+
}
120+
121+
fn repair_from_verify_inner(
122+
file_set: &Par2FileSet,
123+
dir: &Path,
124+
verify_result: &VerifyResult,
107125
re_verify: bool,
108126
) -> Result<RepairResult, RepairError> {
109127
if verify_result.all_correct() {

‎tests/repair_scenarios.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn test_repair_from_verify_matches_repair() {
2828

2929
// Method 2: verify then repair_from_verify
3030
let vr = rust_par2::verify(&fs2, tmp2.path());
31-
let r2 = rust_par2::repair_from_verify(&fs2, tmp2.path(), &vr, true).unwrap();
31+
let r2 = rust_par2::repair_from_verify(&fs2, tmp2.path(), &vr).unwrap();
3232

3333
assert_eq!(r1.blocks_repaired, r2.blocks_repaired);
3434
assert_eq!(r1.files_repaired, r2.files_repaired);
@@ -83,7 +83,7 @@ fn test_verify_repair_verify_cycle() {
8383
assert!(pre.repair_possible);
8484

8585
// Repair
86-
let result = rust_par2::repair_from_verify(&file_set, tmp.path(), &pre, true).unwrap();
86+
let result = rust_par2::repair_from_verify(&file_set, tmp.path(), &pre).unwrap();
8787
assert!(result.success);
8888

8989
// Post-repair verify: all intact

0 commit comments

Comments
 (0)