pub mod encrypted_sled;
pub mod kv_manager;
use std::{fs, path::PathBuf};
#[derive(PartialEq)]
pub enum BuildType {
Test,
ProductionNoTdx,
ProductionTdx,
}
pub fn get_db_path(build_type: BuildType) -> String {
let mut root: PathBuf = if build_type == BuildType::ProductionTdx {
"/persist".into()
} else {
std::env::current_dir().expect("could not get home directory")
};
root.push(".entropy");
if build_type == BuildType::Test {
root.push("testing");
} else {
root.push("production");
}
root.push("db");
let result: String = root.clone().display().to_string();
fs::create_dir_all(root)
.unwrap_or_else(|_| panic!("could not create database path at: {}", result.clone()));
result
}
pub fn clean_tests() {
let db_path = get_db_path(BuildType::Test);
if fs::metadata(db_path.clone()).is_ok() {
let _result = std::fs::remove_dir_all(db_path);
}
}