Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/bin/crates-admin/render_readmes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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(())
Expand Down
10 changes: 3 additions & 7 deletions src/bin/crates-admin/upload_index.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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})",
Expand All @@ -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!(
Expand Down