Skip to content

Commit

Permalink
chore: reduce number of clippy warnings when no TLS stack is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Mar 13, 2024
1 parent 1da67fd commit 7a95dc4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::collections::HashMap;
use std::path::PathBuf;

use crate::common::check_target_not_found_err;
use anyhow::{anyhow, bail, ensure, Context, Result};
use directories::ProjectDirs;
use futures_util::stream::StreamExt;
Expand Down Expand Up @@ -452,17 +451,20 @@ pub async fn cache_dir() -> Result<PathBuf> {
}

async fn get_http_client(client_options: &HttpClientOptions) -> Result<reqwest::Client> {
let mut builder = reqwest::ClientBuilder::new();
let builder = reqwest::ClientBuilder::new();

#[cfg(any(feature = "native-tls", feature = "rustls"))]
let builder = {
builder = builder.danger_accept_invalid_certs(client_options.accept_invalid_certificates);
let mut builder =
builder.danger_accept_invalid_certs(client_options.accept_invalid_certificates);

if let Some(root_certs) = &client_options.root_certificate {
let cert = tokio::fs::read(root_certs)
.await
.with_context(|| "Error reading certificate")
.map_err(|err| check_target_not_found_err(err, &root_certs.to_string_lossy()))?;
.map_err(|err| {
crate::common::check_target_not_found_err(err, &root_certs.to_string_lossy())
})?;

builder = builder.add_root_certificate(
reqwest::Certificate::from_pem(&cert)
Expand Down

0 comments on commit 7a95dc4

Please sign in to comment.