Skip to content

Commit 44929c6

Browse files
committed
moved curl to use new execution_context
1 parent d0eb47a commit 44929c6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/bootstrap/src/core/download.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ fn try_run(config: &Config, cmd: &mut Command) -> Result<(), ()> {
2222
config.try_run(cmd)
2323
}
2424

25-
fn extract_curl_version(out: &[u8]) -> semver::Version {
26-
let out = String::from_utf8_lossy(out);
25+
fn extract_curl_version(out: String) -> semver::Version {
2726
// The output should look like this: "curl <major>.<minor>.<patch> ..."
2827
out.lines()
2928
.next()
@@ -32,12 +31,15 @@ fn extract_curl_version(out: &[u8]) -> semver::Version {
3231
.unwrap_or(semver::Version::new(1, 0, 0))
3332
}
3433

35-
fn curl_version() -> semver::Version {
36-
let mut curl = Command::new("curl");
34+
fn curl_version(config: &Config) -> semver::Version {
35+
let mut curl = command("curl");
3736
curl.arg("-V");
38-
let Ok(out) = curl.output() else { return semver::Version::new(1, 0, 0) };
39-
let out = out.stdout;
40-
extract_curl_version(&out)
37+
let curl = curl.run_capture_stdout_exec_ctx(config);
38+
if curl.is_failure() {
39+
return semver::Version::new(1, 0, 0);
40+
}
41+
let output = curl.stdout();
42+
extract_curl_version(output)
4143
}
4244

4345
/// Generic helpers that are useful anywhere in bootstrap.
@@ -267,7 +269,7 @@ impl Config {
267269
curl.arg("--progress-bar");
268270
}
269271
// --retry-all-errors was added in 7.71.0, don't use it if curl is old.
270-
if curl_version() >= semver::Version::new(7, 71, 0) {
272+
if curl_version(self) >= semver::Version::new(7, 71, 0) {
271273
curl.arg("--retry-all-errors");
272274
}
273275
curl.arg(url);

0 commit comments

Comments
 (0)