Fail fast if account paths cannot be canonicalized (#7300) (#7315)

automerge
This commit is contained in:
mergify[bot]
2019-12-05 19:45:39 -08:00
committed by Grimes
parent bae659b9c7
commit a1736606dc
13 changed files with 123 additions and 125 deletions

View File

@ -591,12 +591,28 @@ pub fn main() {
solana_net_utils::parse_port_range(matches.value_of("dynamic_port_range").unwrap())
.expect("invalid dynamic_port_range");
if let Some(account_paths) = matches.value_of("account_paths") {
validator_config.account_paths = Some(account_paths.to_string());
let account_paths = if let Some(account_paths) = matches.value_of("account_paths") {
account_paths.split(',').map(PathBuf::from).collect()
} else {
validator_config.account_paths =
Some(ledger_path.join("accounts").to_str().unwrap().to_string());
}
vec![ledger_path.join("accounts")]
};
// Create and canonicalize account paths to avoid issues with symlink creation
validator_config.account_paths = account_paths
.into_iter()
.map(|account_path| {
match fs::create_dir_all(&account_path).and_then(|_| fs::canonicalize(&account_path)) {
Ok(account_path) => account_path,
Err(err) => {
eprintln!(
"Unable to access account path: {:?}, err: {:?}",
account_path, err
);
exit(1);
}
}
})
.collect();
let snapshot_interval_slots = value_t_or_exit!(matches, "snapshot_interval_slots", usize);
let snapshot_path = ledger_path.clone().join("snapshot");