Skip to content

Commit

Permalink
fix: ensure local cache and registry directories are created if they …
Browse files Browse the repository at this point in the history
…do not exist (#1150)
  • Loading branch information
sasa-tomic authored Dec 13, 2024
1 parent 2c6f8ce commit 9cdd83c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions rs/ic-management-backend/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,18 +901,26 @@ fn node_ip_addr(nr: &NodeRecord) -> Ipv6Addr {
}

pub fn local_cache_path() -> PathBuf {
match std::env::var("LOCAL_REGISTRY_PATH") {
let path = match std::env::var("LOCAL_REGISTRY_PATH") {
Ok(path) => PathBuf::from(path),
Err(_) => match dirs::cache_dir() {
Some(cache_dir) => cache_dir,
None => PathBuf::from("/tmp"),
},
}
.join("ic-registry-cache")
.join("ic-registry-cache");
if !path.exists() {
std::fs::create_dir_all(&path).expect("failed to create local cache directory");
}
path
}

pub fn local_registry_path(network: &Network) -> PathBuf {
local_cache_path().join(Path::new(network.name.as_str())).join("local_registry")
let path = local_cache_path().join(Path::new(network.name.as_str())).join("local_registry");
if !path.exists() {
std::fs::create_dir_all(&path).expect("failed to create local registry directory");
}
path
}

#[allow(dead_code)]
Expand Down

0 comments on commit 9cdd83c

Please sign in to comment.