From 1e466d3374ee6f5d89c5c5e2978f12ba02b4eab9 Mon Sep 17 00:00:00 2001 From: Yuyi-Oak <1722157266@qq.com> Date: Fri, 31 Jul 2026 17:45:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(sync):=20=E8=A7=84=E8=8C=83=20release=20flo?= =?UTF-8?q?w=20=E7=8A=B6=E6=80=81=E7=A0=81=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infrastructure/src/bin/bat_official_sync.rs | 2 +- infrastructure/src/release_flow.rs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/infrastructure/src/bin/bat_official_sync.rs b/infrastructure/src/bin/bat_official_sync.rs index 4ade446..dc22470 100644 --- a/infrastructure/src/bin/bat_official_sync.rs +++ b/infrastructure/src/bin/bat_official_sync.rs @@ -2519,7 +2519,7 @@ fn build_resource_state_report(state_dir: &Path) -> anyhow::Result().ok()) .or_else(|| { if version_state .as_ref() diff --git a/infrastructure/src/release_flow.rs b/infrastructure/src/release_flow.rs index 35cfd18..3419008 100644 --- a/infrastructure/src/release_flow.rs +++ b/infrastructure/src/release_flow.rs @@ -147,7 +147,7 @@ impl ReleaseFlowStatusCode { } /// Parses a status code read from a persisted daemon/RPC snapshot. - pub fn from_str(code: &str) -> Option { + fn parse_wire_code(code: &str) -> Option { Some(match code { "official.unavailable" => Self::OfficialUnavailable, "official.checking" => Self::OfficialChecking, @@ -255,6 +255,14 @@ impl ReleaseFlowStatusCode { } } +impl std::str::FromStr for ReleaseFlowStatusCode { + type Err = (); + + fn from_str(code: &str) -> Result { + Self::parse_wire_code(code).ok_or(()) + } +} + #[cfg(test)] mod tests { use super::ReleaseFlowStatusCode; @@ -292,4 +300,11 @@ mod tests { assert_eq!(labels.len(), unique.len()); assert!(labels.iter().all(|label| label.contains('.'))); } + + #[test] + fn status_codes_round_trip_through_from_str() { + let code = ReleaseFlowStatusCode::LocalizedPublished; + assert_eq!(code.as_str().parse::(), Ok(code)); + assert!("unknown.status".parse::().is_err()); + } }