From 3aff91f9b7815ce698195f10fcb5cb6d7cdb0d94 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Sun, 22 Jan 2023 13:39:48 +0100 Subject: [PATCH] Correctly initialize home in `Profile::init` --- radicle-node/src/tests/e2e.rs | 2 +- radicle/src/profile.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/radicle-node/src/tests/e2e.rs b/radicle-node/src/tests/e2e.rs index aea1cbf6..b7582af2 100644 --- a/radicle-node/src/tests/e2e.rs +++ b/radicle-node/src/tests/e2e.rs @@ -88,7 +88,7 @@ impl Node { .take(8) .collect::(), ); - let home = Home::init(home).unwrap(); + let home = Home::new(home).init().unwrap(); let signer = MockSigner::default(); let storage = Storage::open(home.storage()).unwrap(); diff --git a/radicle/src/profile.rs b/radicle/src/profile.rs index 4ffe8cca..efd1aa57 100644 --- a/radicle/src/profile.rs +++ b/radicle/src/profile.rs @@ -67,6 +67,7 @@ pub struct Profile { impl Profile { pub fn init(home: Home, passphrase: impl Into) -> Result { + 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 for Home { } impl Home { - pub fn init(home: impl Into) -> Result { - let paths = Self::new(home); - fs::create_dir_all(paths.node()).ok(); + pub fn init(self) -> Result { + fs::create_dir_all(self.node()).ok(); - Ok(paths) + Ok(self) } pub fn new(home: impl Into) -> Self {