mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
clean the header folder in sandbox (#2716)
* forgot to clean the header folder in sandbox in #2685
This commit is contained in:
parent
cea1390df0
commit
340070f0f7
2 changed files with 16 additions and 2 deletions
|
@ -852,7 +852,9 @@ impl Chain {
|
||||||
|
|
||||||
/// Clean the temporary sandbox folder
|
/// Clean the temporary sandbox folder
|
||||||
pub fn clean_txhashset_sandbox(&self) {
|
pub fn clean_txhashset_sandbox(&self) {
|
||||||
txhashset::clean_txhashset_folder(&env::temp_dir());
|
let sandbox_dir = env::temp_dir();
|
||||||
|
txhashset::clean_txhashset_folder(&sandbox_dir);
|
||||||
|
txhashset::clean_header_folder(&sandbox_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes a reading view on a txhashset state that's been provided to us.
|
/// Writes a reading view on a txhashset state that's been provided to us.
|
||||||
|
@ -879,6 +881,7 @@ impl Chain {
|
||||||
// Write txhashset to sandbox (in the os temporary directory)
|
// Write txhashset to sandbox (in the os temporary directory)
|
||||||
let sandbox_dir = env::temp_dir();
|
let sandbox_dir = env::temp_dir();
|
||||||
txhashset::clean_txhashset_folder(&sandbox_dir);
|
txhashset::clean_txhashset_folder(&sandbox_dir);
|
||||||
|
txhashset::clean_header_folder(&sandbox_dir);
|
||||||
txhashset::zip_write(sandbox_dir.clone(), txhashset_data.try_clone()?, &header)?;
|
txhashset::zip_write(sandbox_dir.clone(), txhashset_data.try_clone()?, &header)?;
|
||||||
|
|
||||||
let mut txhashset = txhashset::TxHashSet::open(
|
let mut txhashset = txhashset::TxHashSet::open(
|
||||||
|
@ -949,7 +952,7 @@ impl Chain {
|
||||||
|
|
||||||
// Move sandbox to overwrite
|
// Move sandbox to overwrite
|
||||||
txhashset.release_backend_files();
|
txhashset.release_backend_files();
|
||||||
txhashset::txhashset_replace(sandbox_dir, PathBuf::from(self.db_root.clone()))?;
|
txhashset::txhashset_replace(sandbox_dir.clone(), PathBuf::from(self.db_root.clone()))?;
|
||||||
|
|
||||||
// Re-open on db root dir
|
// Re-open on db root dir
|
||||||
txhashset = txhashset::TxHashSet::open(
|
txhashset = txhashset::TxHashSet::open(
|
||||||
|
@ -959,6 +962,7 @@ impl Chain {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.rebuild_header_mmr(&Tip::from_header(&header), &mut txhashset)?;
|
self.rebuild_header_mmr(&Tip::from_header(&header), &mut txhashset)?;
|
||||||
|
txhashset::clean_header_folder(&sandbox_dir);
|
||||||
|
|
||||||
// Replace the chain txhashset with the newly built one.
|
// Replace the chain txhashset with the newly built one.
|
||||||
*txhashset_ref = txhashset;
|
*txhashset_ref = txhashset;
|
||||||
|
|
|
@ -1494,6 +1494,16 @@ pub fn clean_txhashset_folder(root_dir: &PathBuf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clean the header folder
|
||||||
|
pub fn clean_header_folder(root_dir: &PathBuf) {
|
||||||
|
let header_path = root_dir.clone().join(HEADERHASHSET_SUBDIR);
|
||||||
|
if header_path.exists() {
|
||||||
|
if let Err(e) = fs::remove_dir_all(header_path.clone()) {
|
||||||
|
warn!("clean_header_folder: fail on {:?}. err: {}", header_path, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn expected_file(path: &Path) -> bool {
|
fn expected_file(path: &Path) -> bool {
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
Loading…
Reference in a new issue