Merge #83: fix installer: check if setup exists before install
8903dedaf556d0032b4f72e76b78fc0b58b44e0d fix installer: check if setup exists before install (edouard)
Pull request description:
ACKs for top commit:
edouardparis:
Self-ACK 8903dedaf556d0032b4f72e76b78fc0b58b44e0d
Tree-SHA512: c2e97dc5cf8949d635ef5d6a441532c56e66df8121edf91088c3860450062a52c3ade5b757af891a49abac09318ffcc92896863abe784b1e1a7f1b78ed1fe48d
This commit is contained in:
commit
e69d354e89
@ -50,7 +50,7 @@ impl Installer {
|
||||
should_exit: false,
|
||||
current: 0,
|
||||
steps: vec![
|
||||
Welcome::new(network).into(),
|
||||
Welcome::new(network, destination_path.clone()).into(),
|
||||
DefineDescriptor::new().into(),
|
||||
RegisterDescriptor::default().into(),
|
||||
DefineBitcoind::new().into(),
|
||||
|
||||
@ -63,11 +63,18 @@ impl Context {
|
||||
|
||||
pub struct Welcome {
|
||||
network: bitcoin::Network,
|
||||
data_dir: PathBuf,
|
||||
}
|
||||
|
||||
impl Welcome {
|
||||
pub fn new(network: bitcoin::Network) -> Self {
|
||||
Self { network }
|
||||
pub fn new(network: bitcoin::Network, data_dir: PathBuf) -> Self {
|
||||
Self { network, data_dir }
|
||||
}
|
||||
|
||||
fn valid(&self) -> bool {
|
||||
let mut network_datadir = self.data_dir.clone();
|
||||
network_datadir.push(self.network.to_string());
|
||||
!network_datadir.exists()
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,13 +90,7 @@ impl Step for Welcome {
|
||||
true
|
||||
}
|
||||
fn view(&self) -> Element<Message> {
|
||||
view::welcome(&self.network)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Welcome {
|
||||
fn default() -> Self {
|
||||
Self::new(bitcoin::Network::Bitcoin)
|
||||
view::welcome(&self.network, self.valid())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,17 +27,21 @@ const NETWORKS: [bitcoin::Network; 4] = [
|
||||
bitcoin::Network::Regtest,
|
||||
];
|
||||
|
||||
pub fn welcome(network: &bitcoin::Network) -> Element<Message> {
|
||||
pub fn welcome(network: &bitcoin::Network, valid: bool) -> Element<Message> {
|
||||
container(container(
|
||||
column()
|
||||
.push(container(
|
||||
pick_list(&NETWORKS[..], Some(*network), message::Message::Network).padding(10),
|
||||
))
|
||||
.push(
|
||||
button::primary(None, "Install")
|
||||
.on_press(Message::Next)
|
||||
.width(Length::Units(200)),
|
||||
)
|
||||
.push(if valid {
|
||||
container(
|
||||
button::primary(None, "Start the install")
|
||||
.on_press(Message::Next)
|
||||
.width(Length::Units(200)),
|
||||
)
|
||||
} else {
|
||||
card::warning("A data directory already exists for this network")
|
||||
})
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.padding(100)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user