Fixed FatDB check (#2443)

This commit is contained in:
Arkadiy Paronyan 2016-10-03 19:31:50 +02:00 committed by GitHub
parent e1d3b3fff8
commit 10d572e24f

View File

@ -253,16 +253,17 @@ pub fn tracing_switch_to_bool(switch: Switch, user_defaults: &UserDefaults) -> R
} }
pub fn fatdb_switch_to_bool(switch: Switch, user_defaults: &UserDefaults, algorithm: Algorithm) -> Result<bool, String> { pub fn fatdb_switch_to_bool(switch: Switch, user_defaults: &UserDefaults, algorithm: Algorithm) -> Result<bool, String> {
if algorithm != Algorithm::Archive { let result = match (user_defaults.is_first_launch, switch, user_defaults.fat_db) {
return Err("Fat DB is not supported with the chosen pruning option. Please rerun with `--pruning=archive`".into());
}
match (user_defaults.is_first_launch, switch, user_defaults.fat_db) {
(false, Switch::On, false) => Err("FatDB resync required".into()), (false, Switch::On, false) => Err("FatDB resync required".into()),
(_, Switch::On, _) => Ok(true), (_, Switch::On, _) => Ok(true),
(_, Switch::Off, _) => Ok(false), (_, Switch::Off, _) => Ok(false),
(_, Switch::Auto, def) => Ok(def), (_, Switch::Auto, def) => Ok(def),
};
if result.clone().unwrap_or(false) && algorithm != Algorithm::Archive {
return Err("Fat DB is not supported with the chosen pruning option. Please rerun with `--pruning=archive`".into());
} }
result
} }
#[cfg(test)] #[cfg(test)]