build-manifest: use var_os instead of var to check if vars exist

This will prevent the tool mistakenly ignoring the variables if they
happen to contain non-utf8 data.
This commit is contained in:
Pietro Albini 2020-10-12 19:34:01 +02:00
parent f3d07b36ed
commit cbded3e193
No known key found for this signature in database
GPG Key ID: 3E06ABE80BAAF19C
1 changed files with 3 additions and 3 deletions

View File

@ -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()
};