use std::path::PathBuf;
use crate::server::error::AppError;
pub(in crate::server::handlers::agent_api) fn get_data_dir() -> Result<PathBuf, AppError> {
let dir = crate::core::paths::bamboo_dir();
if !dir.exists() {
std::fs::create_dir_all(&dir).map_err(|error| {
AppError::InternalError(anyhow::anyhow!(
"Could not create bamboo data directory: {}",
error
))
})?;
}
dir.canonicalize().map_err(|error| {
AppError::InternalError(anyhow::anyhow!(
"Could not canonicalize bamboo data directory: {}",
error
))
})
}
pub(in crate::server::handlers::agent_api) fn data_home_file(
file_name: &str,
) -> Result<PathBuf, AppError> {
Ok(crate::core::paths::bamboo_dir().join(file_name))
}