Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Correctly initialize home in `Profile::init`
Alexis Sellier committed 3 years ago
commit 3aff91f9b7815ce698195f10fcb5cb6d7cdb0d94
parent 87ff1990c03962a87c71591761b3cc335e26bf52
2 files changed +5 -5
modified radicle-node/src/tests/e2e.rs
@@ -88,7 +88,7 @@ impl Node {
                .take(8)
                .collect::<String>(),
        );
-
        let home = Home::init(home).unwrap();
+
        let home = Home::new(home).init().unwrap();
        let signer = MockSigner::default();
        let storage = Storage::open(home.storage()).unwrap();

modified radicle/src/profile.rs
@@ -67,6 +67,7 @@ pub struct Profile {

impl Profile {
    pub fn init(home: Home, passphrase: impl Into<Passphrase>) -> Result<Self, Error> {
+
        let home = home.init()?;
        let storage = Storage::open(home.storage())?;
        let keystore = Keystore::new(&home.keys());
        let public_key = keystore.init("radicle", passphrase)?;
@@ -170,11 +171,10 @@ impl From<PathBuf> for Home {
}

impl Home {
-
    pub fn init(home: impl Into<PathBuf>) -> Result<Self, io::Error> {
-
        let paths = Self::new(home);
-
        fs::create_dir_all(paths.node()).ok();
+
    pub fn init(self) -> Result<Self, io::Error> {
+
        fs::create_dir_all(self.node()).ok();

-
        Ok(paths)
+
        Ok(self)
    }

    pub fn new(home: impl Into<PathBuf>) -> Self {