mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 14:14:53 +08:00
fix(sync): 固化 release flow 状态码
This commit is contained in:
@@ -28,6 +28,7 @@ use crate::path_security::{
|
||||
ensure_path_within_root, ensure_safe_directory_path, ensure_safe_file_target, lexical_absolute,
|
||||
read_file_no_symlink, validate_output_root, write_file_atomic, STATE_FILE_MODE,
|
||||
};
|
||||
use crate::release_flow::ReleaseFlowStatusCode;
|
||||
use crate::{
|
||||
build_official_pull_plan_for_platform_inventory, build_official_sync_plan,
|
||||
changed_endpoint_urls, default_official_platforms, DownloadError,
|
||||
@@ -227,6 +228,16 @@ impl OfficialUpdateStatus {
|
||||
Self::Downloaded => "downloaded",
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the stable cross-module flow status code.
|
||||
pub const fn flow_status_code(self) -> ReleaseFlowStatusCode {
|
||||
match self {
|
||||
Self::UpToDate => ReleaseFlowStatusCode::OfficialUpToDate,
|
||||
Self::WouldDownload => ReleaseFlowStatusCode::OfficialUpdateAvailable,
|
||||
Self::WaitingForOfficialResources => ReleaseFlowStatusCode::OfficialWaitingForResources,
|
||||
Self::Downloaded => ReleaseFlowStatusCode::OfficialPublished,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Publication state for localized resources associated with an official release.
|
||||
@@ -247,6 +258,15 @@ impl LocalizedReleaseStatus {
|
||||
Self::Localized => "localized",
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the stable status code for an official release that is known
|
||||
/// to match the currently selected localized state.
|
||||
pub const fn flow_status_code(self) -> ReleaseFlowStatusCode {
|
||||
match self {
|
||||
Self::NotLocalized => ReleaseFlowStatusCode::LocalizedPending,
|
||||
Self::Localized => ReleaseFlowStatusCode::LocalizedPublished,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshot of the official JP update state observed at a point in time.
|
||||
@@ -712,6 +732,8 @@ impl OfficialVerificationSummary {
|
||||
pub struct OfficialUpdateReport {
|
||||
/// Final update status.
|
||||
pub update_status: OfficialUpdateStatus,
|
||||
/// Stable cross-module flow status code.
|
||||
pub status_code: ReleaseFlowStatusCode,
|
||||
/// Selected connection group.
|
||||
pub connection_group: String,
|
||||
/// Selected app version.
|
||||
@@ -842,6 +864,8 @@ pub struct OfficialUpdateReport {
|
||||
pub struct OfficialUpdateProgress {
|
||||
/// Stable progress stage label.
|
||||
pub stage: &'static str,
|
||||
/// Stable cross-module flow status code derived from `stage`.
|
||||
pub status_code: ReleaseFlowStatusCode,
|
||||
/// Human-readable status line.
|
||||
pub message: String,
|
||||
/// One-based download index when the event represents URL download work.
|
||||
@@ -877,6 +901,7 @@ impl OfficialUpdateProgress {
|
||||
pub fn new(stage: &'static str, message: impl Into<String>) -> Self {
|
||||
Self {
|
||||
stage,
|
||||
status_code: ReleaseFlowStatusCode::from_progress_stage(stage),
|
||||
message: message.into(),
|
||||
download_index: None,
|
||||
download_total: None,
|
||||
@@ -1579,6 +1604,11 @@ impl OfficialUpdateService {
|
||||
} else {
|
||||
OfficialUpdateStatus::UpToDate
|
||||
},
|
||||
status_code: if should_download {
|
||||
ReleaseFlowStatusCode::OfficialUpdateAvailable
|
||||
} else {
|
||||
ReleaseFlowStatusCode::OfficialUpToDate
|
||||
},
|
||||
connection_group: current_snapshot.connection_group_name.clone(),
|
||||
app_version: current_snapshot.app_version.clone(),
|
||||
bundle_version: current_snapshot.bundle_version.clone(),
|
||||
@@ -1942,6 +1972,7 @@ impl OfficialUpdateService {
|
||||
};
|
||||
|
||||
report.update_status = OfficialUpdateStatus::Downloaded;
|
||||
report.status_code = report.update_status.flow_status_code();
|
||||
report.active_resource_root = published_version_path.clone();
|
||||
report.published_version_path = Some(published_version_path.clone());
|
||||
report.snapshot_path = final_snapshot_path.clone();
|
||||
@@ -2404,6 +2435,7 @@ fn waiting_for_official_resources_report(
|
||||
let localized_info = localized_release_info_for(config, Some(active_release_id.as_str()));
|
||||
OfficialUpdateReport {
|
||||
update_status: OfficialUpdateStatus::WaitingForOfficialResources,
|
||||
status_code: ReleaseFlowStatusCode::OfficialWaitingForResources,
|
||||
connection_group: base_snapshot.connection_group_name.clone(),
|
||||
app_version: base_snapshot.app_version.clone(),
|
||||
bundle_version: base_snapshot.bundle_version.clone(),
|
||||
|
||||
Reference in New Issue
Block a user