Skip to content

Commit e021fe8

Browse files
committed
jobs/delete_crate: Run deletions concurrently
1 parent 087cd6b commit e021fe8

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/worker/jobs/delete_crate.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::worker::Environment;
33
use anyhow::Context;
44
use crates_io_worker::BackgroundJob;
55
use std::sync::Arc;
6+
use tokio::try_join;
67

78
/// A background job that deletes all files associated with a crate from the storage backend.
89
#[derive(Serialize, Deserialize)]
@@ -24,18 +25,24 @@ impl BackgroundJob for DeleteCrateFromStorage {
2425
async fn run(&self, ctx: Self::Context) -> anyhow::Result<()> {
2526
let name = &self.name;
2627

27-
info!("{name}: Deleting crate files from S3…");
28-
let result = ctx.storage.delete_all_crate_files(name).await;
29-
result.context("Failed to delete crate files from S3")?;
30-
31-
info!("{name}: Deleting readme files from S3…");
32-
let result = ctx.storage.delete_all_readmes(name).await;
33-
result.context("Failed to delete readme files from S3")?;
34-
35-
info!("{name}: Deleting RSS feed from S3…");
36-
let feed_id = FeedId::Crate { name };
37-
let result = ctx.storage.delete_feed(&feed_id).await;
38-
result.context("Failed to delete RSS feed from S3")?;
28+
try_join!(
29+
async {
30+
info!("{name}: Deleting crate files from S3…");
31+
let result = ctx.storage.delete_all_crate_files(name).await;
32+
result.context("Failed to delete crate files from S3")
33+
},
34+
async {
35+
info!("{name}: Deleting readme files from S3…");
36+
let result = ctx.storage.delete_all_readmes(name).await;
37+
result.context("Failed to delete readme files from S3")
38+
},
39+
async {
40+
info!("{name}: Deleting RSS feed from S3…");
41+
let feed_id = FeedId::Crate { name };
42+
let result = ctx.storage.delete_feed(&feed_id).await;
43+
result.context("Failed to delete RSS feed from S3")
44+
}
45+
)?;
3946

4047
info!("{name}: Successfully deleted crate from S3");
4148
Ok(())

0 commit comments

Comments
 (0)