mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 07:16:45 +08:00
@@ -314,6 +314,50 @@ impl ExtendedSnapshotDelta {
|
||||
}
|
||||
}
|
||||
|
||||
/// Structured verification summary for CLI and JSON reports.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct OfficialVerificationSummary {
|
||||
/// Number of resources verified by the local download manifest's path,
|
||||
/// byte size, and BLAKE3 digest.
|
||||
pub local_manifest_blake3_verified_count: usize,
|
||||
/// Number of resources that still need local repair after manifest audit.
|
||||
pub local_manifest_repair_needed_count: usize,
|
||||
/// Human-facing description of the local manifest validation boundary.
|
||||
pub local_manifest_blake3_scope: String,
|
||||
/// Number of official seed `.bytes`/`.hash` pairs verified by the official
|
||||
/// decimal xxHash32 rule.
|
||||
pub official_hash_verified_count: usize,
|
||||
/// Human-facing description of the official hash validation boundary.
|
||||
pub official_hash_scope: String,
|
||||
/// Number of ZIP files that passed structural validation.
|
||||
pub zip_structure_verified_count: usize,
|
||||
/// Human-facing description of the ZIP structure validation boundary.
|
||||
pub zip_structure_scope: String,
|
||||
}
|
||||
|
||||
impl OfficialVerificationSummary {
|
||||
/// Creates a verification summary from validation counters.
|
||||
pub fn new(
|
||||
local_manifest_blake3_verified_count: usize,
|
||||
local_manifest_repair_needed_count: usize,
|
||||
official_hash_verified_count: usize,
|
||||
zip_structure_verified_count: usize,
|
||||
) -> Self {
|
||||
Self {
|
||||
local_manifest_blake3_verified_count,
|
||||
local_manifest_repair_needed_count,
|
||||
local_manifest_blake3_scope:
|
||||
"本地 download manifest 的 URL/path、size 和 BLAKE3 复用校验".to_string(),
|
||||
official_hash_verified_count,
|
||||
official_hash_scope: "官方 seed .bytes/.hash 对,按官方十进制 xxHash32(seed=0) 强校验"
|
||||
.to_string(),
|
||||
zip_structure_verified_count,
|
||||
zip_structure_scope:
|
||||
"所有 .zip 文件的 EOCD、central directory、local header 和边界结构校验".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Structured report returned by an official update run.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct OfficialUpdateReport {
|
||||
@@ -381,6 +425,8 @@ pub struct OfficialUpdateReport {
|
||||
pub transferred_bytes: u64,
|
||||
/// Number of official seed hashes verified.
|
||||
pub official_seed_hash_verified_count: usize,
|
||||
/// Verification summary with explicit boundaries for each validation type.
|
||||
pub verification_summary: OfficialVerificationSummary,
|
||||
/// Download manifest path.
|
||||
pub download_manifest: PathBuf,
|
||||
/// Snapshot path written after success.
|
||||
@@ -683,6 +729,14 @@ impl OfficialUpdateService {
|
||||
.as_ref()
|
||||
.map(|audit| audit.repair_needed_count())
|
||||
.unwrap_or(0);
|
||||
let local_manifest_blake3_verified_count = local_audit
|
||||
.as_ref()
|
||||
.map(|audit| audit.manifest_blake3_verified_count())
|
||||
.unwrap_or(0);
|
||||
let local_zip_structure_verified_count = local_audit
|
||||
.as_ref()
|
||||
.map(|audit| audit.zip_structure_verified_count())
|
||||
.unwrap_or(0);
|
||||
let repair_needed = config.repair
|
||||
&& local_audit
|
||||
.as_ref()
|
||||
@@ -743,6 +797,12 @@ impl OfficialUpdateService {
|
||||
final_bytes: 0,
|
||||
transferred_bytes: 0,
|
||||
official_seed_hash_verified_count: 0,
|
||||
verification_summary: OfficialVerificationSummary::new(
|
||||
local_manifest_blake3_verified_count,
|
||||
local_manifest_repair_needed_count,
|
||||
0,
|
||||
local_zip_structure_verified_count,
|
||||
),
|
||||
download_manifest: fetcher.download_manifest_path(),
|
||||
snapshot_written: None,
|
||||
};
|
||||
@@ -830,6 +890,12 @@ impl OfficialUpdateService {
|
||||
report.official_seed_hash_verified_count = pull_report.official_hash_verified_count();
|
||||
report.local_manifest_verified_count = final_audit.verified_count();
|
||||
report.local_manifest_repair_needed_count = final_audit.repair_needed_count();
|
||||
report.verification_summary = OfficialVerificationSummary::new(
|
||||
final_audit.manifest_blake3_verified_count(),
|
||||
final_audit.repair_needed_count(),
|
||||
pull_report.official_hash_verified_count(),
|
||||
final_audit.zip_structure_verified_count(),
|
||||
);
|
||||
report.snapshot_written = Some(snapshot_path);
|
||||
|
||||
progress(OfficialUpdateProgress::new(
|
||||
|
||||
Reference in New Issue
Block a user