Skip to content

Commit

Permalink
feat(dashboard): Support setting the ic repo cache dir from env
Browse files Browse the repository at this point in the history
  • Loading branch information
sasa-tomic committed Jan 4, 2024
1 parent 29f654a commit f649f18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
19 changes: 15 additions & 4 deletions rs/ic-management-backend/src/git_ic_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,22 @@ pub struct IcRepo {
impl IcRepo {
// Initialize the IcRepo struct with optional depth for shallow clone
pub fn new(depth: Option<usize>) -> anyhow::Result<Self> {
let repo_path = std::env::var("HOME").unwrap_or(".".to_string()) + "/.cache/git/ic";
let lock_file_path = format!("{}.lock", &repo_path);
info!("IC git repo path: {}, lock file path: {}", &repo_path, &lock_file_path);
let repo_path = match std::env::var("REPO_CACHE_PATH") {
Ok(path) => PathBuf::from(path),
Err(_) => match dirs::cache_dir() {
Some(cache_dir) => cache_dir,
None => PathBuf::from("/tmp"),
},
}
.join("git")
.join("ic");
let lock_file_path = format!("{}.lock", &repo_path.display());
info!(
"IC git repo path: {}, lock file path: {}",
&repo_path.display(),
&lock_file_path
);

let repo_path = PathBuf::from(repo_path);
if !repo_path.exists() {
std::fs::create_dir_all(&repo_path).map_err(|e| IoError::Io {
source: e,
Expand Down
19 changes: 1 addition & 18 deletions rs/ic-management-backend/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl RegistryState {
operators: BTreeMap::new(),
factsdb_guests: Vec::new(),
replica_releases: Vec::new(),
ic_repo: Some(IcRepo::new(Some(1000)).expect("failed to init ic repo")),
ic_repo: Some(IcRepo::new(None).expect("failed to init ic repo")),
known_subnets: [
(
"uzr34-akd3s-xrdag-3ql62-ocgoh-ld2ao-tamcv-54e7j-krwgb-2gm4z-oqe",
Expand Down Expand Up @@ -1035,23 +1035,6 @@ async fn fetch_and_add_factsdb_guests_to_registry(
) {
let guests_result = factsdb::query_guests(gitlab_client_release_repo.clone(), target_network.to_string()).await;

let guests_result = if matches!(target_network, Network::Mainnet) {
let guests_result_old = factsdb::query_guests(
gitlab_client_release_repo.clone(),
target_network.legacy_name().to_string(),
)
.await;
guests_result.and_then(|guests_decentralized| {
guests_result_old.map(|guests_old| {
guests_decentralized
.into_iter()
.chain(guests_old.into_iter())
.collect::<Vec<_>>()
})
})
} else {
guests_result
};
match guests_result {
Ok(factsdb_guests) => {
let mut registry_state = registry_state.write().await;
Expand Down

0 comments on commit f649f18

Please sign in to comment.