From b6d8bc94897cd547bf564f574349d22659ad28f6 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 21 Dec 2023 15:38:46 +0000 Subject: [PATCH] cli: fix check for synced replicas If the expected replica count had exceeded the amount of seeds already synced with the following message would appear: Not connected to any seeds for {rid}. This is not true, since there are seeds that were already synced. This is fixed by calculating the `synced` and `connected` nodes, without the local peer in the set. This means that the check for `synced.len() >= connected.len()` will get a hit and the function will correctly return early. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/src/commands/sync.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/radicle-cli/src/commands/sync.rs b/radicle-cli/src/commands/sync.rs index 63700d44..3fb33a0a 100644 --- a/radicle-cli/src/commands/sync.rs +++ b/radicle-cli/src/commands/sync.rs @@ -398,15 +398,21 @@ fn announce_refs( } } RepoSync::Replicas(replicas) => { - let synced = synced.collect::>(); - if synced.len() >= seeds.len() { + let synced = synced + .filter(|s| &s.nid != profile.id()) + .collect::>(); + let connected = seeds + .connected() + .filter(|s| &s.nid != profile.id()) + .collect::>(); + if synced.len() >= connected.len() { term::success!( "Nothing to announce, already in sync with network (see `rad sync status`)" ); return Ok(()); } // Replicas not counting our local replica. - let remotes = synced.iter().filter(|s| &s.nid != profile.id()).count(); + let remotes = synced.len(); if remotes >= replicas { term::success!("Nothing to announce, already in sync with {remotes} seed(s) (see `rad sync status`)"); return Ok(());