1#[cfg(not(target_arch = "wasm32"))]
2use std::path::{Path, PathBuf};
3
4#[cfg(not(target_arch = "wasm32"))]
5pub mod package_cache;
6#[cfg(not(target_arch = "wasm32"))]
7pub mod run_exports_cache;
8
9#[cfg(not(target_arch = "wasm32"))]
10pub mod validation;
11
12mod consts;
13pub use consts::{EXEC_ENVS_DIR, PACKAGE_CACHE_DIR, REPODATA_CACHE_DIR, RUN_EXPORTS_CACHE_DIR};
14
15#[cfg(not(target_arch = "wasm32"))]
19pub fn default_cache_dir() -> anyhow::Result<PathBuf> {
20 std::env::var("RATTLER_CACHE_DIR")
21 .map(PathBuf::from)
22 .or_else(|_| {
23 dirs::cache_dir()
24 .ok_or_else(|| {
25 anyhow::anyhow!("could not determine cache directory for current platform")
26 })
27 .map(|mut p| {
29 p.push("rattler");
30 p.push("cache");
31 p
32 })
33 })
34}
35
36#[cfg(not(target_arch = "wasm32"))]
45pub fn ensure_cache_dir(path: &Path) -> std::io::Result<()> {
46 fs_err::create_dir_all(path)?;
47 rattler_conda_types::backup::exclude_from_backups(path)?;
48 Ok(())
49}