diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-05-01 16:42:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 16:42:05 -0400 |
commit | 913176313b6869eeb29b8d48e0c8d80227fa6544 (patch) | |
tree | cc0128b36ea9b22207a3dd41a401ae4ecd131e74 /cli/tools | |
parent | ecc70eb58fd5531f3b93402cf781e93ef2bb4d64 (diff) |
perf: lazily create RootCertStore (#18938)
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/installer.rs | 2 | ||||
-rw-r--r-- | cli/tools/run.rs | 2 | ||||
-rw-r--r-- | cli/tools/standalone.rs | 2 | ||||
-rw-r--r-- | cli/tools/upgrade.rs | 12 |
4 files changed, 11 insertions, 7 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index fb83c3cab..07606d5f8 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -133,7 +133,7 @@ pub async fn infer_name_from_url(url: &Url) -> Option<String> { let mut url = url.clone(); if url.path() == "/" { - let client = HttpClient::new(None, None).unwrap(); + let client = HttpClient::new(None, None); if let Ok(res) = client.get_redirected_response(url.clone()).await { url = res.url().clone(); } diff --git a/cli/tools/run.rs b/cli/tools/run.rs index c6e706285..99312d5b9 100644 --- a/cli/tools/run.rs +++ b/cli/tools/run.rs @@ -35,7 +35,7 @@ To grant permissions, set them before the script argument. For example: // map specified and bare specifier is used on the command line let factory = CliFactory::from_flags(flags).await?; let deno_dir = factory.deno_dir()?; - let http_client = factory.http_client()?; + let http_client = factory.http_client(); let cli_options = factory.cli_options(); // Run a background task that checks for available upgrades. If an earlier diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index 0e8d9ca73..d34e5da83 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -26,7 +26,7 @@ pub async fn compile( let factory = CliFactory::from_flags(flags).await?; let cli_options = factory.cli_options(); let file_fetcher = factory.file_fetcher()?; - let http_client = factory.http_client()?; + let http_client = factory.http_client(); let deno_dir = factory.deno_dir()?; let module_graph_builder = factory.module_graph_builder().await?; let parsed_source_cache = factory.parsed_source_cache()?; diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index c76d36777..b5aefe479 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -26,6 +26,7 @@ use std::ops::Sub; use std::path::Path; use std::path::PathBuf; use std::process::Command; +use std::sync::Arc; use std::time::Duration; static ARCHIVE_NAME: Lazy<String> = @@ -50,13 +51,13 @@ trait UpdateCheckerEnvironment: Clone + Send + Sync { #[derive(Clone)] struct RealUpdateCheckerEnvironment { - http_client: HttpClient, + http_client: Arc<HttpClient>, cache_file_path: PathBuf, current_time: chrono::DateTime<chrono::Utc>, } impl RealUpdateCheckerEnvironment { - pub fn new(http_client: HttpClient, cache_file_path: PathBuf) -> Self { + pub fn new(http_client: Arc<HttpClient>, cache_file_path: PathBuf) -> Self { Self { http_client, cache_file_path, @@ -183,7 +184,10 @@ fn print_release_notes(current_version: &str, new_version: &str) { } } -pub fn check_for_upgrades(http_client: HttpClient, cache_file_path: PathBuf) { +pub fn check_for_upgrades( + http_client: Arc<HttpClient>, + cache_file_path: PathBuf, +) { if env::var("DENO_NO_UPDATE_CHECK").is_ok() { return; } @@ -264,7 +268,7 @@ pub async fn upgrade( upgrade_flags: UpgradeFlags, ) -> Result<(), AnyError> { let factory = CliFactory::from_flags(flags).await?; - let client = factory.http_client()?; + let client = factory.http_client(); let current_exe_path = std::env::current_exe()?; let metadata = fs::metadata(¤t_exe_path)?; let permissions = metadata.permissions(); |