diff --git a/build.rs b/build.rs index ac52ba1ff..2f5bd20ac 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -use std::path::Path; +use std::path::PathBuf; use std::{env, fs}; fn main() { @@ -8,8 +8,7 @@ fn main() { } fn breaking_changes() { - let out_dir_s = &env::var("OUT_DIR").unwrap(); - let out_dir = Path::new(out_dir_s); + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let version_str = env::var("CARGO_PKG_VERSION").unwrap(); let changelog = parse_changelog::parse(include_str!("CHANGELOG.md")).expect("Invalid CHANGELOG.md"); let release = changelog diff --git a/src/config.rs b/src/config.rs index 19168a171..018052f94 100644 --- a/src/config.rs +++ b/src/config.rs @@ -761,25 +761,25 @@ impl ConfigFile { let mut res = Vec::new(); let dir_to_search = config_directory.join("topgrade.d"); - if dir_to_search.exists() { - for entry in fs::read_dir(dir_to_search)? { - let entry = entry?; - // Use `Path::is_file()` here to traverse symbolic links. - // `DirEntry::file_type()` and `FileType::is_file()` will not traverse symbolic links. - if entry.path().is_file() { - debug!( - "Found additional (directory) configuration file at {}", - entry.path().display() - ); - res.push(entry.path()); - } - } - res.sort(); - } else { + if !dir_to_search.exists() { debug!("No additional configuration directory exists, creating one"); fs::create_dir_all(&dir_to_search)?; } + for entry in fs::read_dir(&dir_to_search)? { + let entry_path = entry?.path(); + + if entry_path.is_file() { + debug!( + "Found additional (directory) configuration file at {}", + entry_path.display() + ); + res.push(entry_path); + } + } + + res.sort(); + Ok(res) } diff --git a/src/steps/node.rs b/src/steps/node.rs index c778b2391..6159d3744 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -302,7 +302,7 @@ impl VitePlus { let vp_home = match std::env::var_os("VP_HOME") { None => return Ok(false), Some(s) if s.is_empty() => return Ok(false), - Some(s) => s, + Some(s) => PathBuf::from(s), }; let uid = Uid::effective();