Blow away snapshots directory on start (#5446)

This commit is contained in:
carllin
2019-08-06 21:41:38 -07:00
committed by GitHub
parent 9dcf3347f5
commit b72c5689c9
5 changed files with 23 additions and 22 deletions

View File

@ -357,7 +357,6 @@ impl BankForks {
snapshot_config: &SnapshotConfig,
snapshot_tar: P,
) -> Result<Self> {
fs::create_dir_all(&snapshot_config.snapshot_path)?;
// Untar the snapshot into a temp directory under `snapshot_config.snapshot_path()`
let unpack_dir = tempfile::tempdir_in(snapshot_config.snapshot_path())?;
untar_snapshot_in(&snapshot_tar, &unpack_dir)?;

View File

@ -26,6 +26,7 @@ use solana_sdk::poh_config::PohConfig;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::timing::{timestamp, DEFAULT_SLOTS_PER_TURN};
use std::fs;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
@ -317,6 +318,11 @@ fn get_bank_forks(
if snapshot_config.is_some() {
let snapshot_config = snapshot_config.as_ref().unwrap();
// Blow away any remnants in the snapshots directory
let _ = fs::remove_dir_all(snapshot_config.snapshot_path());
fs::create_dir_all(&snapshot_config.snapshot_path())
.expect("Couldn't create snapshot directory");
// Get the path to the tar
let tar = snapshot_utils::get_snapshot_tar_path(
&snapshot_config.snapshot_package_output_path(),