unify error and success handling in extractors

This commit is contained in:
theubusu
2026-02-17 18:34:46 +01:00
parent aa2249f024
commit 10dd854685
29 changed files with 58 additions and 100 deletions
+5 -7
View File
@@ -47,8 +47,7 @@ pub fn extract_epk2(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
matching_key = Some(key_bytes);
header = decrypt_aes_ecb_auto(matching_key.as_ref().unwrap(), &stored_header)?;
} else {
println!("No valid key found!");
return Ok(());
return Err("No valid key found!".into());
}
}
//parse header
@@ -86,8 +85,7 @@ pub fn extract_epk2(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
println!("Found correct key: {}", key_name);
matching_key = Some(key_bytes);
} else {
println!("No valid key found!");
return Ok(());
return Err("No valid key found!".into());
}
}
let matching_key_bytes = matching_key.as_ref().unwrap();
@@ -109,7 +107,9 @@ pub fn extract_epk2(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
pak_header = pak_header_reader.read_le()?;
}
assert!(i == pak_header.segment_index, "Unexpected segment index in pak header!, expected: {}, got: {}", i , pak_header.segment_index);
if i != pak_header.segment_index {
return Err(format!("Unexpected segment index in pak header!, expected: {}, got: {}", i , pak_header.segment_index).into());
}
let actual_segment_size =
// check if this is the last segment and not the last PAK
@@ -144,7 +144,5 @@ pub fn extract_epk2(app_ctx: &AppContext, _ctx: Box<dyn Any>) -> Result<(), Box<
}
}
println!("\nExtraction finished!");
Ok(())
}