Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Improve sync errors
cloudhead committed 2 years ago
commit a60afc8350b1ae538cf87450fab20b1813e5af2f
parent 92d6fd4c7e85ebb2a045068fb8b61edc1f7ba099
2 files changed +22 -3
modified radicle-cli/examples/rad-sync.md
@@ -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
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.
+

+

+
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
+
```
modified radicle-cli/src/commands/sync.rs
@@ -288,8 +288,10 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
                let success = results.success().count();
                let failed = results.failed().count();

-
                if success == 0 {
-
                    anyhow::bail!("repository fetch from {failed} seed(s) failed");
+
                if results.is_empty() {
+
                    term::error(format!("no seeds found for {rid}"));
+
                } else if success == 0 {
+
                    term::error(format!("repository fetch from {failed} seed(s) failed"));
                } else {
                    term::success!("Fetched repository from {success} seed(s)");
                }
@@ -381,7 +383,11 @@ fn announce_refs(
    mut node: Node,
    profile: &Profile,
) -> 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 unsynced: Vec<_> = if doc.visibility.is_public() {
        let seeds = node.seeds(rid)?;