mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 08:26:44 +08:00
@@ -1,7 +1,7 @@
|
||||
use bat_adapters::official::yostar_jp::PatchPlatform;
|
||||
use bat_infrastructure::{
|
||||
OfficialServerInfoSource, OfficialUpdateConfig, OfficialUpdateProgress, OfficialUpdateReport,
|
||||
OfficialUpdateService, OfficialUpdateStatus,
|
||||
OfficialUpdateService, OfficialUpdateStatus, OfficialVerificationSummary,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
@@ -1523,6 +1523,32 @@ fn print_list(label: &str, values: &[String], limit: usize) {
|
||||
}
|
||||
}
|
||||
|
||||
fn print_verification_summary(summary: &OfficialVerificationSummary) {
|
||||
println!(" 校验摘要:");
|
||||
for line in verification_summary_lines(summary) {
|
||||
println!(" - {line}");
|
||||
}
|
||||
}
|
||||
|
||||
fn verification_summary_lines(summary: &OfficialVerificationSummary) -> Vec<String> {
|
||||
vec![
|
||||
format!(
|
||||
"官方 .hash 强校验: {} 对 ({})",
|
||||
summary.official_hash_verified_count, summary.official_hash_scope
|
||||
),
|
||||
format!(
|
||||
"本地 BLAKE3 复用校验: {} 项通过, {} 项需修复 ({})",
|
||||
summary.local_manifest_blake3_verified_count,
|
||||
summary.local_manifest_repair_needed_count,
|
||||
summary.local_manifest_blake3_scope
|
||||
),
|
||||
format!(
|
||||
"ZIP 结构校验: {} 个 ZIP 通过 ({})",
|
||||
summary.zip_structure_verified_count, summary.zip_structure_scope
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
fn format_bool(value: bool) -> &'static str {
|
||||
if value {
|
||||
"yes"
|
||||
@@ -1590,6 +1616,7 @@ impl HumanReport for OfficialUpdateReport {
|
||||
print_field("本地校验通过", self.local_manifest_verified_count);
|
||||
print_field("需修复", self.local_manifest_repair_needed_count);
|
||||
print_field("官方 hash 校验", self.official_seed_hash_verified_count);
|
||||
print_verification_summary(&self.verification_summary);
|
||||
print_field("catalog marker", self.addressables_marker_checked_count);
|
||||
print_list("变更 endpoint", &self.changed_endpoint_urls, 8);
|
||||
print_list("计划 URL", &self.download_urls, 8);
|
||||
@@ -1684,6 +1711,7 @@ impl HumanReport for VerifyCommandReport {
|
||||
print_field("本地失败数", self.local_manifest_failure_count);
|
||||
print_field("官方 hash 对", self.official_hash_pair_count);
|
||||
print_field("官方 hash 通过", self.official_hash_verified_count);
|
||||
print_verification_summary(&self.verification_summary);
|
||||
if !self.official_hash_errors.is_empty() {
|
||||
print_list("官方 hash 错误", &self.official_hash_errors, 8);
|
||||
}
|
||||
@@ -1798,6 +1826,7 @@ struct VerifyCommandReport {
|
||||
local_manifest_failure_count: usize,
|
||||
official_hash_pair_count: usize,
|
||||
official_hash_verified_count: usize,
|
||||
verification_summary: OfficialVerificationSummary,
|
||||
official_hash_errors: Vec<String>,
|
||||
failures: Vec<VerificationItemReport>,
|
||||
}
|
||||
@@ -1837,6 +1866,12 @@ fn run_verify_command(options: &CliOptions) -> anyhow::Result<bool> {
|
||||
let healthy = update_report.update_status == OfficialUpdateStatus::UpToDate
|
||||
&& update_report.local_manifest_repair_needed_count == 0
|
||||
&& verification.is_clean();
|
||||
let verification_summary = OfficialVerificationSummary::new(
|
||||
verification.manifest_blake3_verified_count(),
|
||||
verification.failure_count(),
|
||||
verification.official_hash_verified_count,
|
||||
verification.zip_structure_verified_count(),
|
||||
);
|
||||
let report = VerifyCommandReport {
|
||||
command: "verify",
|
||||
status: if healthy { "verified" } else { "failed" },
|
||||
@@ -1854,6 +1889,7 @@ fn run_verify_command(options: &CliOptions) -> anyhow::Result<bool> {
|
||||
local_manifest_failure_count: verification.failure_count(),
|
||||
official_hash_pair_count: verification.official_hash_pair_count,
|
||||
official_hash_verified_count: verification.official_hash_verified_count,
|
||||
verification_summary,
|
||||
official_hash_errors: verification.official_hash_errors,
|
||||
failures,
|
||||
};
|
||||
@@ -3384,6 +3420,26 @@ mod tests {
|
||||
assert!(STARTUP_BANNER.contains("BlueArchiveToolkit"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verification_summary_output_names_all_validation_types() {
|
||||
let summary = OfficialVerificationSummary::new(7, 1, 2, 3);
|
||||
let lines = verification_summary_lines(&summary);
|
||||
|
||||
assert_eq!(lines.len(), 3);
|
||||
assert!(lines[0].contains("官方 .hash 强校验"));
|
||||
assert!(lines[0].contains("xxHash32"));
|
||||
assert!(lines[1].contains("本地 BLAKE3 复用校验"));
|
||||
assert!(lines[1].contains("需修复"));
|
||||
assert!(lines[2].contains("ZIP 结构校验"));
|
||||
assert!(lines[2].contains("central directory"));
|
||||
|
||||
let json = serde_json::to_value(&summary).unwrap();
|
||||
assert_eq!(json["official_hash_verified_count"], 2);
|
||||
assert_eq!(json["local_manifest_blake3_verified_count"], 7);
|
||||
assert_eq!(json["local_manifest_repair_needed_count"], 1);
|
||||
assert_eq!(json["zip_structure_verified_count"], 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn daemon_socket_path_uses_state_dir() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user