Correctly initialize home in `Profile::init`

This commit is contained in:
Alexis Sellier 2023-01-22 13:39:48 +01:00
parent 87ff1990c0
commit 3aff91f9b7
No known key found for this signature in database
2 changed files with 5 additions and 5 deletions

View File

@ -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();

View File

@ -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 {