zebra_state::config

Function check_and_delete_old_databases

source
pub fn check_and_delete_old_databases(
    config: &Config,
    db_kind: impl AsRef<str>,
    major_version: u64,
    network: &Network,
) -> JoinHandle<()>
Expand description

Spawns a task that checks if there are old database folders, and deletes them from the filesystem.

Iterate over the files and directories in the databases folder and delete if:

  • The db_kind directory exists.
  • The entry in db_kind is a directory.
  • The directory name has a prefix v.
  • The directory name without the prefix can be parsed as an unsigned number.
  • The parsed number is lower than the major_version.

The network is used to generate the path, then ignored. If config is an ephemeral database, no databases are deleted.

§Panics

If the path doesn’t match the expected db_kind/major_version/network format.