Skip to content

Commit

Permalink
build-manifest: use var_os instead of var to check if vars exist
Browse files Browse the repository at this point in the history
This will prevent the tool mistakenly ignoring the variables if they
happen to contain non-utf8 data.
  • Loading branch information
pietroalbini committed Oct 12, 2020
1 parent f3d07b3 commit cbded3e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tools/build-manifest/src/main.rs
Expand Up @@ -205,13 +205,13 @@ fn main() {
//
// Once the old release process is fully decommissioned, the environment variable, all the
// related code in this tool and ./x.py dist hash-and-sign can be removed.
let legacy = env::var("BUILD_MANIFEST_LEGACY").is_ok();
let legacy = env::var_os("BUILD_MANIFEST_LEGACY").is_some();

let num_threads = if legacy {
// Avoid overloading the old server in legacy mode.
1
} else if let Ok(num) = env::var("BUILD_MANIFEST_NUM_THREADS") {
num.parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
} else if let Some(num) = env::var_os("BUILD_MANIFEST_NUM_THREADS") {
num.to_str().unwrap().parse().expect("invalid number for BUILD_MANIFEST_NUM_THREADS")
} else {
num_cpus::get()
};
Expand Down

0 comments on commit cbded3e

Please sign in to comment.