Delete full db directory with purge-chain subcommand (#1786)

Closes #1767 

Until now the `purge-chain` command would only remove the `full`
subfolder of the db folder. However there is also the `parachains` db
that currently remains and can cause problems on node restart.

Example wiht old code:
```
polkadot purge-chain --database paritydb --base-path /tmp/some-folder
Are you sure to remove "/tmp/some-folder/chains/polkadot/paritydb/full"? [y/N]: y
"/tmp/some-folder/chains/polkadot/paritydb/full" removed.
```
In this case `/tmp/some-folder/chains/polkadot/paritydb/parachains`
would remain and might cause problem on node restart because of version
conflicts as described in #1767. After this PR the whole
`/tmp/some-folder/chains/polkadot/paritydb` folder will be deleted.
This commit is contained in:
Sebastian Kunert
2023-10-05 18:44:03 +02:00
committed by GitHub
parent 51c0c24213
commit d21113c13f
2 changed files with 1 additions and 5 deletions
@@ -48,7 +48,7 @@ pub struct PurgeChainCmd {
impl PurgeChainCmd {
/// Run the purge command
pub fn run(&self, database_config: DatabaseSource) -> error::Result<()> {
let db_path = database_config.path().ok_or_else(|| {
let db_path = database_config.path().and_then(|p| p.parent()).ok_or_else(|| {
error::Error::Input("Cannot purge custom database implementation".into())
})?;