Skip to content

Commit 087cd6b

Browse files
committed
jobs/delete_crate: Ensure job fails if files failed to delete
This ensures that the background job will be retried if a deletion was unsuccessful.
1 parent 71a2842 commit 087cd6b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/worker/jobs/delete_crate.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::storage::FeedId;
22
use crate::worker::Environment;
3+
use anyhow::Context;
34
use crates_io_worker::BackgroundJob;
45
use std::sync::Arc;
56

@@ -24,20 +25,17 @@ impl BackgroundJob for DeleteCrateFromStorage {
2425
let name = &self.name;
2526

2627
info!("{name}: Deleting crate files from S3…");
27-
if let Err(error) = ctx.storage.delete_all_crate_files(name).await {
28-
warn!("{name}: Failed to delete crate files from S3: {error}");
29-
}
28+
let result = ctx.storage.delete_all_crate_files(name).await;
29+
result.context("Failed to delete crate files from S3")?;
3030

3131
info!("{name}: Deleting readme files from S3…");
32-
if let Err(error) = ctx.storage.delete_all_readmes(name).await {
33-
warn!("{name}: Failed to delete readme files from S3: {error}");
34-
}
32+
let result = ctx.storage.delete_all_readmes(name).await;
33+
result.context("Failed to delete readme files from S3")?;
3534

3635
info!("{name}: Deleting RSS feed from S3…");
3736
let feed_id = FeedId::Crate { name };
38-
if let Err(error) = ctx.storage.delete_feed(&feed_id).await {
39-
warn!("{name}: Failed to delete RSS feed from S3: {error}");
40-
}
37+
let result = ctx.storage.delete_feed(&feed_id).await;
38+
result.context("Failed to delete RSS feed from S3")?;
4139

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

0 commit comments

Comments
 (0)