diff --git a/oma-topics/src/lib.rs b/oma-topics/src/lib.rs index 79a70d4a1..f158911cb 100644 --- a/oma-topics/src/lib.rs +++ b/oma-topics/src/lib.rs @@ -207,7 +207,7 @@ impl<'a> TopicManager<'a> { } /// Enable select topic - pub fn add(&mut self, topic: &str) -> Result<()> { + pub fn add(&mut self, topic: &str) -> Result { debug!("oma will opt_in: {}", topic); let index = self @@ -220,11 +220,13 @@ impl<'a> TopicManager<'a> { debug!("Enabled: {enabled_names:?}"); if let Some(index) = index { + let ic = index.clone(); + let icc = index.clone(); if !enabled_names.contains(&&index.name) { - self.enabled.push(index.clone()); + self.enabled.push(ic); } - return Ok(()); + return Ok(icc); } debug!("index: {index:?} does not exist"); diff --git a/src/subcommand/topics.rs b/src/subcommand/topics.rs index 1d1104a77..62bb397c5 100644 --- a/src/subcommand/topics.rs +++ b/src/subcommand/topics.rs @@ -450,8 +450,11 @@ async fn topics_inner( .unwrap()?; } + let mut enabled_pkgs = vec![]; + for i in opt_in { - tm.add(i)?; + let t = tm.add(i)?; + enabled_pkgs.extend(t.packages); } let mut downgrade_pkgs = vec![]; @@ -460,12 +463,6 @@ async fn topics_inner( downgrade_pkgs.extend(removed_topic.packages); } - let enabled_pkgs = tm - .enabled_topics() - .iter() - .flat_map(|x| x.packages.clone()) - .collect::>(); - Ok(TopicChanged { enabled_pkgs, downgrade_pkgs,