From 29a32ac519b0dcb875fb6971e8d853ef6a8b5742 Mon Sep 17 00:00:00 2001 From: Jan Koscisz Date: Wed, 7 Dec 2022 11:35:07 +0100 Subject: [PATCH 1/3] fix clashing args in purge-chain cmd --- bin/node/src/commands.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/node/src/commands.rs b/bin/node/src/commands.rs index ddbea7e3e5..ce171318e8 100644 --- a/bin/node/src/commands.rs +++ b/bin/node/src/commands.rs @@ -303,7 +303,14 @@ pub struct PurgeChainCmd { impl PurgeChainCmd { pub fn run(&self, database_config: DatabaseSource) -> Result<(), Error> { self.purge_chain.run(database_config)?; - self.purge_backup.run(self.purge_chain.yes) + self.purge_backup.run( + self.purge_chain.yes, + self.purge_chain + .shared_params + .base_path() + .expect("need base-path to be provided") + .expect("need base-path to be provided"), + ) } } @@ -319,16 +326,14 @@ impl CliConfiguration for PurgeChainCmd { #[derive(Debug, Parser)] pub struct PurgeBackupCmd { - #[clap(flatten)] - pub node_params: NodeParams, + /// Directory under which AlephBFT backup is stored + #[arg(long, default_value = DEFAULT_BACKUP_FOLDER)] + pub backup_dir: String, } impl PurgeBackupCmd { - pub fn run(&self, skip_prompt: bool) -> Result<(), Error> { - let backup_path = backup_path( - self.node_params.base_path().path(), - self.node_params.backup_dir(), - ); + pub fn run(&self, skip_prompt: bool, base_path: BasePath) -> Result<(), Error> { + let backup_path = backup_path(base_path.path(), &self.backup_dir); if !skip_prompt { print!( From bcc186f6e4fdac0991016d704e23d3505ae7290c Mon Sep 17 00:00:00 2001 From: Jan Koscisz Date: Wed, 7 Dec 2022 15:15:53 +0100 Subject: [PATCH 2/3] review --- bin/node/src/commands.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/node/src/commands.rs b/bin/node/src/commands.rs index ce171318e8..59d77721c0 100644 --- a/bin/node/src/commands.rs +++ b/bin/node/src/commands.rs @@ -307,9 +307,8 @@ impl PurgeChainCmd { self.purge_chain.yes, self.purge_chain .shared_params - .base_path() - .expect("need base-path to be provided") - .expect("need base-path to be provided"), + .base_path()? + .ok_or_else(|| Error::Input("need base-path to be provided".to_string()))?, ) } } From 054839c11426f3d86006a6c76966c9aebefcb6a8 Mon Sep 17 00:00:00 2001 From: Jan Koscisz Date: Wed, 7 Dec 2022 16:25:33 +0100 Subject: [PATCH 3/3] review --- bin/node/src/commands.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/node/src/commands.rs b/bin/node/src/commands.rs index 59d77721c0..3d9af7179a 100644 --- a/bin/node/src/commands.rs +++ b/bin/node/src/commands.rs @@ -302,14 +302,14 @@ pub struct PurgeChainCmd { impl PurgeChainCmd { pub fn run(&self, database_config: DatabaseSource) -> Result<(), Error> { - self.purge_chain.run(database_config)?; self.purge_backup.run( self.purge_chain.yes, self.purge_chain .shared_params .base_path()? .ok_or_else(|| Error::Input("need base-path to be provided".to_string()))?, - ) + )?; + self.purge_chain.run(database_config) } }