diff --git a/src/config.rs b/src/config.rs index e25efb0..54f8593 100644 --- a/src/config.rs +++ b/src/config.rs @@ -592,7 +592,7 @@ impl<'a> Config<'a> { } } else if let Some(config_value) = &raw_config.directories.cache_dir { // Resolve possible ~ prefixed path - let expanded_path = expand_path(config_value, home_path.as_ref())?; + let expanded_path = expand_home(config_value, home_path.as_ref())?; // Resolve possible relative path. let resolved_path = relative_path_root.join(expanded_path); @@ -616,7 +616,7 @@ impl<'a> Config<'a> { .as_ref() .map(|path| -> Result { // Resolve possible ~ prefixed path - let expanded_path = expand_path(path, home_path.as_ref())?; + let expanded_path = expand_home(path, home_path.as_ref())?; // Resolve possible relative path. let resolved_path = relative_path_root.join(expanded_path); @@ -654,7 +654,7 @@ impl<'a> Config<'a> { } /// Expands tilde (~) prefixed directories into its absolute version -fn expand_path<'a>(input_path: &'a PathBuf, home_path: Option<&PathBuf>) -> Result> { +fn expand_home<'a>(input_path: &'a PathBuf, home_path: Option<&PathBuf>) -> Result> { if input_path.is_absolute() { return Ok(Cow::Borrowed(input_path)); } @@ -834,7 +834,7 @@ mod test { let path_to_expand = PathBuf::from("~/baz"); assert_eq!( - *expand_path(&path_to_expand, home.as_ref()).unwrap(), + *expand_home(&path_to_expand, home.as_ref()).unwrap(), PathBuf::from("/foo/bar/baz") ); } @@ -845,7 +845,7 @@ mod test { let dir_to_expand = PathBuf::from("/one/two"); assert_eq!( - *expand_path(&dir_to_expand, home.as_ref()).unwrap(), + *expand_home(&dir_to_expand, home.as_ref()).unwrap(), dir_to_expand ); } @@ -855,7 +855,7 @@ mod test { let home = Some(PathBuf::from("/foo/bar")); let dir_to_expand = PathBuf::from("~baz/foo"); - assert!(expand_path(&dir_to_expand, home.as_ref()).is_err()); + assert!(expand_home(&dir_to_expand, home.as_ref()).is_err()); } #[test]