#[cfg(not(target_arch = "wasm32"))]
use std::path::{Path, PathBuf};
#[cfg(not(target_arch = "wasm32"))]
pub mod package_cache;
#[cfg(not(target_arch = "wasm32"))]
pub mod run_exports_cache;
#[cfg(not(target_arch = "wasm32"))]
pub mod validation;
mod consts;
pub use consts::{PACKAGE_CACHE_DIR, REPODATA_CACHE_DIR, RUN_EXPORTS_CACHE_DIR};
#[cfg(not(target_arch = "wasm32"))]
pub fn default_cache_dir() -> anyhow::Result<PathBuf> {
std::env::var("RATTLER_CACHE_DIR")
.map(PathBuf::from)
.or_else(|_| {
dirs::cache_dir()
.ok_or_else(|| {
anyhow::anyhow!("could not determine cache directory for current platform")
})
.map(|mut p| {
p.push("rattler");
p.push("cache");
p
})
})
}
#[cfg(not(target_arch = "wasm32"))]
pub fn ensure_cache_dir(path: &Path) -> std::io::Result<()> {
fs_err::create_dir_all(path)?;
rattler_conda_types::backup::exclude_from_backups(path)?;
Ok(())
}