Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete full db directory with purge-chain subcommand #1786

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions polkadot/tests/purge_chain_works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async fn purge_chain_rocksdb_works() {
assert!(cmd.wait().unwrap().success());
assert!(tmpdir.path().join("chains/rococo_dev").exists());
assert!(tmpdir.path().join("chains/rococo_dev/db/full").exists());
assert!(tmpdir.path().join("chains/rococo_dev/db/full/parachains").exists());

// Purge chain
let status = Command::new(cargo_bin("polkadot"))
Expand Down Expand Up @@ -102,7 +101,6 @@ async fn purge_chain_paritydb_works() {
assert!(cmd.wait().unwrap().success());
assert!(tmpdir.path().join("chains/rococo_dev").exists());
assert!(tmpdir.path().join("chains/rococo_dev/paritydb/full").exists());
assert!(tmpdir.path().join("chains/rococo_dev/paritydb/parachains").exists());

// Purge chain
let status = Command::new(cargo_bin("polkadot"))
Expand All @@ -118,8 +116,6 @@ async fn purge_chain_paritydb_works() {
// Make sure that the chain folder exists, but `db/full` is deleted.
assert!(tmpdir.path().join("chains/rococo_dev").exists());
assert!(!tmpdir.path().join("chains/rococo_dev/paritydb/full").exists());
// Parachains removal requires calling "purge-chain --parachains".
assert!(tmpdir.path().join("chains/rococo_dev/paritydb/parachains").exists());
})
.await;
}
2 changes: 1 addition & 1 deletion substrate/client/cli/src/commands/purge_chain_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})?;

Expand Down