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
6 changes: 3 additions & 3 deletions src/bin/crates-admin/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#[macro_use]
extern crate tracing;

mod backfill_og_images;
mod default_versions;
mod delete_crate;
mod delete_version;
mod dialoguer;
mod enqueue_job;
mod migrate;
mod populate;
mod render_og_images;
mod render_readmes;
mod transfer_crates;
mod upload_index;
Expand All @@ -18,7 +18,7 @@ mod yank_version;
#[derive(clap::Parser, Debug)]
#[command(name = "crates-admin")]
enum Command {
BackfillOgImages(backfill_og_images::Opts),
RenderOgImages(render_og_images::Opts),
DeleteCrate(delete_crate::Opts),
DeleteVersion(delete_version::Opts),
Populate(populate::Opts),
Expand Down Expand Up @@ -48,7 +48,7 @@ async fn main() -> anyhow::Result<()> {
span.record("command", tracing::field::debug(&command));

match command {
Command::BackfillOgImages(opts) => backfill_og_images::run(opts).await,
Command::RenderOgImages(opts) => render_og_images::run(opts).await,
Command::DeleteCrate(opts) => delete_crate::run(opts).await,
Command::DeleteVersion(opts) => delete_version::run(opts).await,
Command::Populate(opts) => populate::run(opts).await,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use tracing::{info, warn};

#[derive(clap::Parser, Debug)]
#[command(
name = "backfill-og-images",
about = "Enqueue OG image generation jobs for existing crates"
name = "render-og-images",
about = "Enqueue OG image generation jobs for crates"
)]
pub struct Opts {
#[arg(long, default_value = "1000")]
Expand All @@ -24,12 +24,16 @@ pub struct Opts {
#[arg(long)]
/// Offset to start enqueueing from (useful for resuming)
offset: Option<i64>,

#[arg(long)]
/// Skip CDN cache invalidation when generating OG images
skip_invalidation: bool,
}

pub async fn run(opts: Opts) -> Result<()> {
let mut conn = db::oneoff_connection().await?;

info!("Starting OG image backfill with options: {opts:?}");
info!("Starting OG image rendering with options: {opts:?}");

// Helper function to build query
let build_query = |offset: i64| {
Expand Down Expand Up @@ -79,7 +83,13 @@ pub async fn run(opts: Opts) -> Result<()> {
// Create batch of jobs
let jobs = crate_names
.into_iter()
.map(GenerateOgImage::without_cdn_invalidation)
.map(|crate_name| {
if opts.skip_invalidation {
GenerateOgImage::without_cdn_invalidation(crate_name)
} else {
GenerateOgImage::new(crate_name)
}
})
.map(|job| {
Ok((
background_jobs::job_type.eq(GenerateOgImage::JOB_NAME),
Expand Down