cli: Improve sync errors
In the case where we don't find any seeds, display a better error message. We also don't bail out on error, since the announcement step might still be worth trying.
This commit is contained in:
parent
92d6fd4c7e
commit
a60afc8350
|
|
@ -96,3 +96,16 @@ with 1 node(s)`. This does not necessarily mean that only `bob` or
|
||||||
`eve` were synchronized with, since they both could have received the
|
`eve` were synchronized with, since they both could have received the
|
||||||
announcement of the new changes. However, it does mean that we only
|
announcement of the new changes. However, it does mean that we only
|
||||||
wait for at least 1 of the nodes to have fetched the changes from us.
|
wait for at least 1 of the nodes to have fetched the changes from us.
|
||||||
|
|
||||||
|
|
||||||
|
It's also possible to receive an error if a repository is not found anywhere.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ rad seed rad:z39mP9rQAaGmERfUMPULfPUi473tY
|
||||||
|
✓ Seeding policy updated for rad:z39mP9rQAaGmERfUMPULfPUi473tY with scope 'all'
|
||||||
|
```
|
||||||
|
``` (fail)
|
||||||
|
$ rad sync rad:z39mP9rQAaGmERfUMPULfPUi473tY
|
||||||
|
✗ Error: no seeds found for rad:z39mP9rQAaGmERfUMPULfPUi473tY
|
||||||
|
✗ Error: nothing to announce, repository rad:z39mP9rQAaGmERfUMPULfPUi473tY is not available locally
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -288,8 +288,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
let success = results.success().count();
|
let success = results.success().count();
|
||||||
let failed = results.failed().count();
|
let failed = results.failed().count();
|
||||||
|
|
||||||
if success == 0 {
|
if results.is_empty() {
|
||||||
anyhow::bail!("repository fetch from {failed} seed(s) failed");
|
term::error(format!("no seeds found for {rid}"));
|
||||||
|
} else if success == 0 {
|
||||||
|
term::error(format!("repository fetch from {failed} seed(s) failed"));
|
||||||
} else {
|
} else {
|
||||||
term::success!("Fetched repository from {success} seed(s)");
|
term::success!("Fetched repository from {success} seed(s)");
|
||||||
}
|
}
|
||||||
|
|
@ -381,7 +383,11 @@ fn announce_refs(
|
||||||
mut node: Node,
|
mut node: Node,
|
||||||
profile: &Profile,
|
profile: &Profile,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let repo = profile.storage.repository(rid)?;
|
let Ok(repo) = profile.storage.repository(rid) else {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"nothing to announce, repository {rid} is not available locally"
|
||||||
|
));
|
||||||
|
};
|
||||||
let doc = repo.identity_doc()?;
|
let doc = repo.identity_doc()?;
|
||||||
let unsynced: Vec<_> = if doc.visibility.is_public() {
|
let unsynced: Vec<_> = if doc.visibility.is_public() {
|
||||||
let seeds = node.seeds(rid)?;
|
let seeds = node.seeds(rid)?;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue