fix(sync): 补齐发布清理与校验进度

This commit is contained in:
2026-07-31 13:00:53 +08:00
parent 8ec0e12795
commit 16e73327b4
4 changed files with 592 additions and 62 deletions
+39 -3
View File
@@ -32,9 +32,10 @@ use crate::{
build_official_pull_plan_for_platform_inventory, build_official_sync_plan,
changed_endpoint_urls, default_official_platforms, DownloadError,
OfficialGameMainConfigBootstrapService, OfficialLauncherBootstrapService,
OfficialResourcePullPlan, OfficialResourcePullProgress, OfficialResourcePullProgressKind,
OfficialResourcePullService, YostarJpLauncherCdnConfig, YostarJpLauncherGameConfig,
YostarJpLauncherManifestUrl, YostarJpLauncherRemoteManifest,
OfficialResourceHashVerification, OfficialResourcePullPlan, OfficialResourcePullProgress,
OfficialResourcePullProgressKind, OfficialResourcePullService, OfficialResourceVerification,
YostarJpLauncherCdnConfig, YostarJpLauncherGameConfig, YostarJpLauncherManifestUrl,
YostarJpLauncherRemoteManifest,
};
use crate::{
read_parse_cache_at, OfficialParseCacheService, OfficialParseConfig, OfficialParseSummary,
@@ -865,6 +866,10 @@ pub struct OfficialUpdateProgress {
pub download_failure_attempts: Option<usize>,
/// Whether the URL was recorded in the quarantine manifest.
pub download_quarantined: Option<bool>,
/// Local size/BLAKE3/ZIP verification for a completed URL.
pub download_verification: Option<OfficialResourceVerification>,
/// Official `.hash` sidecar verification when a seed catalog pair passes.
pub official_hash_verification: Option<OfficialResourceHashVerification>,
}
impl OfficialUpdateProgress {
@@ -884,6 +889,8 @@ impl OfficialUpdateProgress {
download_failure_retryable: None,
download_failure_attempts: None,
download_quarantined: None,
download_verification: None,
official_hash_verification: None,
}
}
@@ -906,6 +913,8 @@ impl OfficialUpdateProgress {
self.download_failure_attempts = event.failure_attempts;
self.download_quarantined =
(event.kind == OfficialResourcePullProgressKind::Failed).then_some(event.quarantined);
self.download_verification = event.verification.clone();
self.official_hash_verification = event.official_hash.clone();
self
}
}
@@ -1808,6 +1817,18 @@ impl OfficialUpdateService {
&config.curl_command,
)
.with_proxy_config(config.curl_proxy.clone());
let pruned_stale_resource_count = staging_fetcher
.prune_stale_manifest_entries(&pull_plan)
.map_err(anyhow::Error::msg)?;
if pruned_stale_resource_count > 0 {
progress(OfficialUpdateProgress::new(
"publish",
format!(
"已清理新 manifest 删除的旧官方资源:{}",
pruned_stale_resource_count
),
));
}
report.staging_path = Some(publish_plan.staging_path.clone());
report.snapshot_path = staging_snapshot_path.clone();
report.download_manifest = staging_fetcher.download_manifest_path();
@@ -2701,6 +2722,21 @@ fn progress_from_pull_event(event: OfficialResourcePullProgress) -> OfficialUpda
),
)
.with_download_progress(&event),
OfficialResourcePullProgressKind::Verification => {
let hash = event.official_hash.as_ref();
OfficialUpdateProgress::new(
"verify",
format!(
"官方 hash 校验通过:算法={} 期望={} 实际={} 数据 URL={} hash URL={}",
hash.map(|value| value.algorithm.as_str()).unwrap_or("unknown"),
hash.map(|value| value.expected.as_str()).unwrap_or("unknown"),
hash.map(|value| value.actual.as_str()).unwrap_or("unknown"),
hash.map(|value| value.data_url.as_str()).unwrap_or(event.url.as_str()),
hash.map(|value| value.hash_url.as_str()).unwrap_or("unknown")
),
)
.with_download_progress(&event)
}
}
}