Create account paths once

(cherry picked from commit fe0ba4a429)
This commit is contained in:
Michael Vines
2021-01-02 17:57:56 -08:00
parent 667402531f
commit 3f3058fc7d

View File

@ -288,6 +288,12 @@ where
map map
}; };
// Ensure all account paths exist
for path in &accounts_db.paths {
std::fs::create_dir_all(path)
.unwrap_or_else(|err| panic!("Failed to create directory {}: {}", path.display(), err));
}
let mut last_log_update = Instant::now(); let mut last_log_update = Instant::now();
let mut remaining_slots_to_process = storage.len(); let mut remaining_slots_to_process = storage.len();
@ -307,8 +313,6 @@ where
let path_index = thread_rng().gen_range(0, accounts_db.paths.len()); let path_index = thread_rng().gen_range(0, accounts_db.paths.len());
let local_dir = &accounts_db.paths[path_index]; let local_dir = &accounts_db.paths[path_index];
std::fs::create_dir_all(local_dir).expect("Create directory failed");
// Move the corresponding AppendVec from the snapshot into the directory pointed // Move the corresponding AppendVec from the snapshot into the directory pointed
// at by `local_dir` // at by `local_dir`
let append_vec_relative_path = AppendVec::new_relative_path(slot, storage_entry.id); let append_vec_relative_path = AppendVec::new_relative_path(slot, storage_entry.id);