Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
helper: Don't sync if we aren't seeding
Alexis Sellier committed 2 years ago
commit 5ae617abf096d31181496e6b5b048e81872c462f
parent 623ef278d001a33d10b3c3d280edd7312002e663
3 files changed +27 -9
modified radicle-cli/examples/git/git-push.md
@@ -71,6 +71,7 @@ error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLr
```

If you pass an unsupported push option, you get an error:
+

``` (stderr) (fail)
$ git push -o alien rad HEAD:alice/2
error: unknown push option "alien"
modified radicle-cli/examples/rad-sync.md
@@ -109,3 +109,13 @@ $ rad sync rad:z39mP9rQAaGmERfUMPULfPUi473tY
✗ Error: no seeds found for rad:z39mP9rQAaGmERfUMPULfPUi473tY
✗ Error: nothing to announce, repository rad:z39mP9rQAaGmERfUMPULfPUi473tY is not available locally
```
+

+
Also note that you cannot sync an unseeded repo:
+
```
+
$ rad unseed rad:z39mP9rQAaGmERfUMPULfPUi473tY
+
[...]
+
```
+
``` (fail)
+
$ rad sync rad:z39mP9rQAaGmERfUMPULfPUi473tY
+
✗ Error: repository rad:z39mP9rQAaGmERfUMPULfPUi473tY is not seeded
+
```
modified radicle-remote-helper/src/push.rs
@@ -90,6 +90,9 @@ pub enum Error {
    /// Patch edit message error.
    #[error(transparent)]
    PatchEdit(#[from] cli::patch::Error),
+
    /// Policy config error.
+
    #[error("node policy: {0}")]
+
    Policy(#[from] node::policy::config::Error),
    /// Patch not found in store.
    #[error("patch `{0}` not found")]
    NotFound(patch::PatchId),
@@ -332,16 +335,20 @@ pub fn run(
        }

        if !opts.no_sync {
-
            // Connect to local node and announce refs to the network.
-
            // If our node is not running, we simply skip this step, as the
-
            // refs will be announced eventually, when the node restarts.
-
            let node = radicle::Node::new(profile.socket());
-
            if node.is_running() {
-
                // Nb. allow this to fail. The push to local storage was still successful.
-
                sync(stored.id, ok.into_values().flatten(), node, profile).ok();
+
            if profile.policies()?.is_seeding(&stored.id)? {
+
                // Connect to local node and announce refs to the network.
+
                // If our node is not running, we simply skip this step, as the
+
                // refs will be announced eventually, when the node restarts.
+
                let node = radicle::Node::new(profile.socket());
+
                if node.is_running() {
+
                    // Nb. allow this to fail. The push to local storage was still successful.
+
                    sync(stored.id, ok.into_values().flatten(), node, profile).ok();
+
                } else if hints {
+
                    hint("offline push, your node is not running");
+
                    hint("to sync with the network, run `rad node start`");
+
                }
            } else if hints {
-
                hint("offline push, your node is not running");
-
                hint("to sync with the network, run `rad node start`");
+
                hint("you are not seeding this repository; skipping sync");
            }
        }
    }