bail!(
        "failed to create data dir `{}`: {err}",
        path.parent().unwrap().display()
      );
    }

    let db_cache_size = match options.db_cache_size {
      Some(db_cache_size) => db_cache_size,
      None => {
        let mut sys = System::new();
        sys.refresh_memory();
        usize::try_from(sys.total_memory() / 4)?
      }
    };

    log::info!("Setting DB cache size to {} bytes", db_cache_size);

    let durability = if cfg!(test) {
      redb::Durability::None
    } else {
      redb::Durability::Immediate
    };

    let index_runes;
    let index_sats;

    let index_path = path.clone();
    let once = Once::new();
    let database = match Database::builder()
      .set_cache_size(db_cache_size)
      .set_repair_callback(move |_| {
        once.call_once(|| {
          println!("Index file `{}` needs recovery. This can take a long time, especially for the --index-sats index.", index_path.display());
        })
      })
      .open(&path)
    {
      Ok(database) => {
        {