Don't delete databases that can be reused

This commit is contained in:
Arya 2024-08-29 22:54:12 -04:00
parent dbf54e4690
commit 06886001aa
1 changed files with 10 additions and 1 deletions

View File

@ -15,7 +15,7 @@ use tracing::Span;
use zebra_chain::parameters::Network;
use crate::{
constants::{DATABASE_FORMAT_VERSION_FILE_NAME, STATE_DATABASE_KIND},
constants::{DATABASE_FORMAT_VERSION_FILE_NAME, RESTORABLE_DB_VERSIONS, STATE_DATABASE_KIND},
state_database_format_version_in_code, BoxError,
};
@ -317,6 +317,15 @@ fn check_and_delete_database(
return None;
}
// Don't delete databases that can be reused.
if RESTORABLE_DB_VERSIONS
.iter()
.map(|v| v - 1)
.any(|v| v == dir_major_version)
{
return None;
}
let outdated_path = entry.path();
// # Correctness