Delete install target datadir in case of failure

close #20
This commit is contained in:
edouard 2022-11-10 12:11:33 +01:00
parent e69d354e89
commit e9fa816be7

View File

@ -114,6 +114,18 @@ impl Installer {
.update(message);
Command::perform(install(self.context.clone()), Message::Installed)
}
Message::Installed(Err(e)) => {
let mut data_dir = self.context.data_dir.clone().unwrap();
data_dir.push(self.context.bitcoin_config.network.to_string());
// In case of failure during install, block the thread to
// deleted the data_dir/network directory in order to start clean again.
std::fs::remove_dir_all(data_dir).expect("Correctly deleted");
self.steps
.get_mut(self.current)
.expect("There is always a step")
.update(Message::Installed(Err(e)));
Command::none()
}
Message::Event(Event::Window(window::Event::CloseRequested)) => {
self.stop();
Command::none()