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 <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
16478e721b
commit
b6d8bc9489
|
|
@ -398,15 +398,21 @@ fn announce_refs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RepoSync::Replicas(replicas) => {
|
RepoSync::Replicas(replicas) => {
|
||||||
let synced = synced.collect::<Vec<_>>();
|
let synced = synced
|
||||||
if synced.len() >= seeds.len() {
|
.filter(|s| &s.nid != profile.id())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let connected = seeds
|
||||||
|
.connected()
|
||||||
|
.filter(|s| &s.nid != profile.id())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
if synced.len() >= connected.len() {
|
||||||
term::success!(
|
term::success!(
|
||||||
"Nothing to announce, already in sync with network (see `rad sync status`)"
|
"Nothing to announce, already in sync with network (see `rad sync status`)"
|
||||||
);
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// Replicas not counting our local replica.
|
// Replicas not counting our local replica.
|
||||||
let remotes = synced.iter().filter(|s| &s.nid != profile.id()).count();
|
let remotes = synced.len();
|
||||||
if remotes >= replicas {
|
if remotes >= replicas {
|
||||||
term::success!("Nothing to announce, already in sync with {remotes} seed(s) (see `rad sync status`)");
|
term::success!("Nothing to announce, already in sync with {remotes} seed(s) (see `rad sync status`)");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue