diff --git a/src/bin/crates-admin/render_readmes.rs b/src/bin/crates-admin/render_readmes.rs index 29868b1566f..2dd5dfb22e3 100644 --- a/src/bin/crates-admin/render_readmes.rs +++ b/src/bin/crates-admin/render_readmes.rs @@ -19,6 +19,7 @@ use flate2::read::GzDecoder; use reqwest::{blocking::Client, header}; use std::str::FromStr; use tar::{self, Archive}; +use tokio::runtime::Handle; const USER_AGENT: &str = "crates-admin"; @@ -121,17 +122,13 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> { println!("[{}-{}] Rendering README...", krate_name, version.num); let readme = get_readme(&storage, &client, &version, &krate_name)?; if !readme.is_empty() { - let rt = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .context("Failed to initialize tokio runtime")?; - - rt.block_on(storage.upload_readme( - &krate_name, - &version.num, - readme.into(), - )) - .context("Failed to upload rendered README file to S3")?; + Handle::current() + .block_on(storage.upload_readme( + &krate_name, + &version.num, + readme.into(), + )) + .context("Failed to upload rendered README file to S3")?; } Ok(()) diff --git a/src/bin/crates-admin/upload_index.rs b/src/bin/crates-admin/upload_index.rs index a03cf35dd6d..d2cba59ee57 100644 --- a/src/bin/crates-admin/upload_index.rs +++ b/src/bin/crates-admin/upload_index.rs @@ -1,9 +1,10 @@ use crate::dialoguer; -use anyhow::{anyhow, Context}; +use anyhow::anyhow; use crates_io::storage::Storage; use crates_io::tasks::spawn_blocking; use crates_io_index::{Repository, RepositoryConfig}; use indicatif::{ProgressBar, ProgressIterator, ProgressStyle}; +use tokio::runtime::Handle; #[derive(clap::Parser, Debug)] #[command( @@ -31,11 +32,6 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> { return Ok(()); } - let rt = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .context("Failed to initialize tokio runtime")?; - let pb = ProgressBar::new(files.len() as u64); pb.set_style(ProgressStyle::with_template( "{bar:60} ({pos}/{len}, ETA {eta})", @@ -59,7 +55,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> { } let contents = std::fs::read_to_string(&path)?; - rt.block_on(storage.sync_index(crate_name, Some(contents)))?; + Handle::current().block_on(storage.sync_index(crate_name, Some(contents)))?; } println!(