@@ -83,32 +83,37 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
8383 let available_at = now + chrono:: TimeDelta :: hours ( opts. availability_delay ) ;
8484
8585 for name in & crate_names {
86- if let Some ( crate_info) = existing_crates. iter ( ) . find ( |info| info. name == * name) {
87- let id = crate_info. id ;
88-
89- let deleted_crate = NewDeletedCrate :: builder ( name)
90- . created_at ( & crate_info. created_at )
91- . deleted_at ( & now)
92- . deleted_by ( deleted_by. id )
93- . maybe_message ( opts. message . as_deref ( ) )
94- . available_at ( & available_at)
95- . build ( ) ;
96-
97- info ! ( "{name}: Deleting crate from the database…" ) ;
98- let result = conn
99- . transaction ( |conn| delete_from_database ( conn, id, deleted_crate) . scope_boxed ( ) )
100- . await ;
101-
102- if let Err ( error) = result {
103- warn ! ( %id, "{name}: Failed to delete crate from the database: {error}" ) ;
86+ let crate_id =
87+ if let Some ( crate_info) = existing_crates. iter ( ) . find ( |info| info. name == * name) {
88+ let id = crate_info. id ;
89+
90+ let deleted_crate = NewDeletedCrate :: builder ( name)
91+ . created_at ( & crate_info. created_at )
92+ . deleted_at ( & now)
93+ . deleted_by ( deleted_by. id )
94+ . maybe_message ( opts. message . as_deref ( ) )
95+ . available_at ( & available_at)
96+ . build ( ) ;
97+
98+ info ! ( "{name}: Deleting crate from the database…" ) ;
99+ let result = conn
100+ . transaction ( |conn| delete_from_database ( conn, id, deleted_crate) . scope_boxed ( ) )
101+ . await ;
102+
103+ if let Err ( error) = result {
104+ warn ! ( %id, "{name}: Failed to delete crate from the database: {error}" ) ;
105+ } ;
106+
107+ Some ( id)
108+ } else {
109+ info ! ( "{name}: Skipped missing crate" ) ;
110+
111+ None
104112 } ;
105- } else {
106- info ! ( "{name}: Skipped missing crate" ) ;
107- } ;
108113
109114 info ! ( "{name}: Enqueuing background jobs…" ) ;
110- let git_index_job = jobs:: SyncToGitIndex :: new ( name) ;
111- let sparse_index_job = jobs:: SyncToSparseIndex :: new ( name) ;
115+ let git_index_job = jobs:: SyncToGitIndex :: new_maybe_deleted ( crate_id , name) ;
116+ let sparse_index_job = jobs:: SyncToSparseIndex :: new_maybe_deleted ( crate_id , name) ;
112117 let delete_from_storage_job = jobs:: DeleteCrateFromStorage :: new ( name. into ( ) ) ;
113118
114119 if let Err ( error) = tokio:: try_join!(
0 commit comments