Skip to content

Commit 0b6b12e

Browse files
committed
admin/delete_crate: Move user confirmation outside of spawn_blocking() callback
1 parent 8bc95d9 commit 0b6b12e

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/admin/delete_crate.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,30 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
6262
entry.1.push(login);
6363
}
6464

65+
println!("Deleting the following crates:");
66+
println!();
67+
for name in &crate_names {
68+
match existing_crates.get(name) {
69+
Some((id, owners)) => {
70+
let owners = owners.join(", ");
71+
println!(" - {name} (id={id}, owners={owners})");
72+
}
73+
None => println!(" - {name} (⚠️ crate not found)"),
74+
}
75+
}
76+
println!();
77+
78+
if !opts.yes
79+
&& !dialoguer::async_confirm("Do you want to permanently delete these crates?").await?
80+
{
81+
return Ok(());
82+
}
83+
6584
spawn_blocking(move || {
6685
use diesel::RunQueryDsl;
6786

6887
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
6988

70-
println!("Deleting the following crates:");
71-
println!();
72-
for name in &crate_names {
73-
match existing_crates.get(name) {
74-
Some((id, owners)) => {
75-
let owners = owners.join(", ");
76-
println!(" - {name} (id={id}, owners={owners})");
77-
}
78-
None => println!(" - {name} (⚠️ crate not found)"),
79-
}
80-
}
81-
println!();
82-
83-
if !opts.yes && !dialoguer::confirm("Do you want to permanently delete these crates?")? {
84-
return Ok(());
85-
}
86-
8789
for name in &crate_names {
8890
if let Some((id, _)) = existing_crates.get(name) {
8991
info!("{name}: Deleting crate from the database…");

0 commit comments

Comments
 (0)