mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
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:
@@ -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"))
|
||||
@@ -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"))
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
})?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user