Skip to content

Commit

Permalink
fix(cmd): check if the ln path that we know are good
Browse files Browse the repository at this point in the history
Sometime we may do operation like delete a directory
that it is linked with coffee, but we forget it.

So this code make sure that we are operating on a safe information.

Link: #209
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Dec 30, 2023
1 parent b32ebff commit 1a5e441
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ impl CoffeeManager {
return Ok(());
}
let root = self.config.cln_root.clone().unwrap();
// We check if there is some problem we the path that we know
if !fs::try_exists(root.clone()).await? {
return Err(error!("lightning root path `{}` do not exist", root));
} else if !fs::try_exists(format!("{root}/{}", self.config.network)).await? {
return Err(error!(
"lightning network path `{root}/{}` do not exist",
self.config.network
));
}
// All safe, we can move with the logic
let rpc = Client::new(format!("{root}/{}/lightning-rpc", self.config.network));
self.rpc = Some(rpc);
let path = self.config.cln_config_path.clone().unwrap();
Expand Down

0 comments on commit 1a5e441

Please sign in to comment.