From 0f4f4a6367e29e7bd72327fc749284a025e11b11 Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Thu, 2 Jul 2026 05:08:42 +0800 Subject: [PATCH] fix(replication): avoid target status map allocation (#4159) --- crates/ecstore/src/object_api/types.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/ecstore/src/object_api/types.rs b/crates/ecstore/src/object_api/types.rs index 2b91e6807..57bde6189 100644 --- a/crates/ecstore/src/object_api/types.rs +++ b/crates/ecstore/src/object_api/types.rs @@ -748,9 +748,14 @@ impl ObjectInfo { } pub fn target_replication_status(&self, arn: &str) -> ReplicationStatusType { - replication_statuses_map(self.replication_status_internal.as_deref().unwrap_or_default()) - .get(arn) - .cloned() + self.replication_status_internal + .as_deref() + .unwrap_or_default() + .split(';') + .find_map(|entry| { + let (target_arn, status) = entry.split_once('=')?; + (!target_arn.is_empty() && target_arn == arn).then(|| ReplicationStatusType::from(status)) + }) .unwrap_or_default() } @@ -843,6 +848,7 @@ mod tests { let state = object.replication_state(); assert_eq!(object.target_replication_status("arn:target-a"), ReplicationStatusType::Completed); + assert_eq!(object.target_replication_status("arn:target-b"), ReplicationStatusType::Failed); assert_eq!(object.target_replication_status("arn:missing"), ReplicationStatusType::Empty); assert_eq!(state.targets.get("arn:target-b"), Some(&ReplicationStatusType::Failed)); assert_eq!(state.purge_targets.get("arn:target-a"), Some(&VersionPurgeStatusType::Pending));