Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into deleted-crates-min-ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
LawnGnome committed Nov 20, 2024
2 parents a1606a8 + 92b8fac commit edbf30a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bin/crates-admin/delete_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub struct Opts {
/// An optional message explaining why the crate was deleted.
#[arg(long)]
message: Option<String>,

/// The amount of time (in hours) before making the crate available
/// for re-registration.
#[arg(long, default_value = "24")]
availability_delay: i64,
}

pub async fn run(opts: Opts) -> anyhow::Result<()> {
Expand Down Expand Up @@ -75,6 +80,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
}

let now = Utc::now();
let available_at = now + chrono::TimeDelta::hours(opts.availability_delay);

for name in &crate_names {
if let Some(crate_info) = existing_crates.iter().find(|info| info.name == *name) {
Expand All @@ -97,7 +103,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
.deleted_at(&now)
.deleted_by(deleted_by.id)
.maybe_message(opts.message.as_deref())
.available_at(&now)
.available_at(&available_at)
.maybe_min_version(min_version.as_deref())
.build();

Expand Down

0 comments on commit edbf30a

Please sign in to comment.