Skip to content

Commit

Permalink
refactor: reuse utility fn to open buffered file
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Oct 14, 2024
1 parent 7439c15 commit 12fc467
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/nextclade-cli/src/io/http_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{Parser, ValueHint};
use eyre::{Report, WrapErr};
use itertools::Itertools;
use log::info;
use nextclade::io::file::open_file_or_stdin;
use nextclade::make_internal_error;
use nextclade::utils::info::{this_package_name, this_package_version_str};
use reqwest::blocking::Client;
Expand All @@ -11,8 +11,6 @@ use rustls_pemfile;
use rustls_pki_types::TrustAnchor;
use rustls_platform_verifier::Verifier;
use std::env;
use std::io::BufReader;
use std::fs::File;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -130,12 +128,9 @@ impl HttpClient {
fn extra_ca_certs<'a>() -> Result<impl IntoIterator<Item = TrustAnchor<'a>>, Report> {
match env::var_os("NEXTCLADE_EXTRA_CA_CERTS") {
Some(filename) => {
let file = File::open(filename.clone())
.wrap_err_with(|| format!("When opening NEXTCLADE_EXTRA_CA_CERTS file {filename:?}"))?;
let mut file = open_file_or_stdin(&Some(filename))?;

let mut reader = BufReader::new(file);

let anchors = rustls_pemfile::certs(&mut reader)
let anchors = rustls_pemfile::certs(&mut file)
.map(|cert| {
let cert = cert.wrap_err("When parsing an extra CA certificate")?;
let anchor =
Expand Down

0 comments on commit 12fc467

Please sign in to comment.