handle not found error in purge-chain (#2274)

This commit is contained in:
Xiliang Chen
2019-04-15 00:57:56 +12:00
committed by Bastian Köcher
parent dcb1cafe2a
commit 72a1c6298e
+12 -5
View File
@@ -39,7 +39,7 @@ use network::{
use primitives::H256;
use std::{
io::{Write, Read, stdin, stdout}, iter, fs::{self, File}, net::{Ipv4Addr, SocketAddr},
io::{Write, Read, stdin, stdout, ErrorKind}, iter, fs::{self, File}, net::{Ipv4Addr, SocketAddr},
path::{Path, PathBuf}, str::FromStr,
};
@@ -673,10 +673,17 @@ where
}
}
fs::remove_dir_all(&db_path)?;
println!("{:?} removed.", &db_path);
Ok(())
match fs::remove_dir_all(&db_path) {
Result::Ok(_) => {
println!("{:?} removed.", &db_path);
Ok(())
},
Result::Err(ref err) if err.kind() == ErrorKind::NotFound => {
println!("{:?} did not exist.", &db_path);
Ok(())
},
Result::Err(err) => Result::Err(err.into())
}
}
fn parse_address(