Skip to content

Commit

Permalink
Generating empty set when /home/razz4780 is not set, regex fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Razz4780 committed Aug 28, 2023
1 parent b592773 commit da5dacc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mirrord/layer/src/file/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ fn generate_remote_ro_set() -> RegexSet {
}

fn generate_not_found_set() -> RegexSet {
let home = env::var("HOME").expect("failed to resolve $HOME");
let Ok(home) = env::var("HOME") else {
tracing::warn!("Unable to resolve $HOME directory, generating empty not-found set");
return Default::default();
};

let home_clean = home.trim_end_matches('/');

let patterns = [r"\.aws", r"\.config/gcloud", r"\.kube", r"\.azure"]
.into_iter()
.map(|cloud_dir| format!("{home_clean}/{cloud_dir}"));
.map(|cloud_dir| format!("^{home_clean}/{cloud_dir}"));

RegexSetBuilder::new(patterns)
.case_insensitive(true)
Expand Down

0 comments on commit da5dacc

Please sign in to comment.