@@ -63,7 +63,7 @@ pub async fn delete_version(
6363 return Ok ( ( ) ) ;
6464 } ;
6565
66- let is_library = delete_version_from_database ( conn, crate_id, version) . await ?;
66+ let is_library = delete_version_from_database ( conn, name , crate_id, version) . await ?;
6767 let paths = if is_library {
6868 LIBRARY_STORAGE_PATHS_TO_DELETE
6969 } else {
@@ -125,6 +125,7 @@ const METADATA: &[(&str, &str)] = &[
125125/// Returns whether this release was a library
126126async fn delete_version_from_database (
127127 conn : & mut sqlx:: PgConnection ,
128+ name : & KrateName ,
128129 crate_id : CrateId ,
129130 version : & Version ,
130131) -> Result < bool > {
@@ -143,6 +144,14 @@ async fn delete_version_from_database(
143144 . await ?
144145 . unwrap_or ( false ) ;
145146
147+ sqlx:: query!(
148+ "DELETE FROM queue WHERE name = $1 AND version = $2;" ,
149+ name as _,
150+ version as _
151+ )
152+ . execute ( & mut * transaction)
153+ . await ?;
154+
146155 update_latest_version_id ( & mut transaction, crate_id) . await ?;
147156
148157 transaction. commit ( ) . await ?;
@@ -171,7 +180,7 @@ async fn delete_crate_from_database(
171180 )
172181 . as_str ( ) ) . bind ( crate_id) . execute ( & mut * transaction) . await ?;
173182 }
174- sqlx:: query!( "DELETE FROM owner_rels WHERE cid = $1;" , crate_id. 0 )
183+ sqlx:: query!( "DELETE FROM owner_rels WHERE cid = $1;" , crate_id as _ )
175184 . execute ( & mut * transaction)
176185 . await ?;
177186
@@ -181,16 +190,19 @@ async fn delete_crate_from_database(
181190 FROM releases
182191 WHERE releases.crate_id = $1
183192 " ,
184- crate_id. 0
193+ crate_id as _
185194 )
186195 . fetch_one ( & mut * transaction)
187196 . await ?
188197 . unwrap_or ( false ) ;
189198
190- sqlx:: query!( "DELETE FROM releases WHERE crate_id = $1;" , crate_id. 0 )
199+ sqlx:: query!( "DELETE FROM releases WHERE crate_id = $1;" , crate_id as _ )
191200 . execute ( & mut * transaction)
192201 . await ?;
193- sqlx:: query!( "DELETE FROM crates WHERE id = $1;" , crate_id. 0 )
202+ sqlx:: query!( "DELETE FROM crates WHERE id = $1;" , crate_id as _)
203+ . execute ( & mut * transaction)
204+ . await ?;
205+ sqlx:: query!( "DELETE FROM queue WHERE name = $1;" , name as _)
194206 . execute ( & mut * transaction)
195207 . await ?;
196208
@@ -253,8 +265,14 @@ mod tests {
253265 async fn test_delete_crate ( archive_storage : bool ) -> Result < ( ) > {
254266 let env = TestEnvironment :: new ( ) . await ?;
255267 let storage = env. storage ( ) ?;
268+ let queue = env. build_queue ( ) ?;
256269 let mut conn = env. async_conn ( ) . await ?;
257270
271+ // crate fake entries in the build queue
272+ queue. add_crate ( & FOO , & V1 , 0 , None ) . await ?;
273+ queue. add_crate ( & FOO , & V2 , 0 , None ) . await ?;
274+ queue. add_crate ( & BAR , & V1 , 0 , None ) . await ?;
275+
258276 // Create fake packages in the database
259277 let pkg1_v1_id = env
260278 . fake_release ( )
@@ -302,6 +320,10 @@ mod tests {
302320
303321 delete_crate ( & mut conn, storage, & FOO ) . await ?;
304322
323+ assert ! ( !queue. has_build_queued( & FOO , & V1 ) . await ?) ;
324+ assert ! ( !queue. has_build_queued( & FOO , & V2 ) . await ?) ;
325+ assert ! ( queue. has_build_queued( & BAR , & V1 ) . await ?) ;
326+
305327 assert ! ( !crate_exists( & mut conn, & FOO ) . await ?) ;
306328 assert ! ( crate_exists( & mut conn, & BAR ) . await ?) ;
307329 assert ! ( !release_exists( & mut conn, pkg1_v1_id) . await ?) ;
@@ -359,6 +381,7 @@ mod tests {
359381 async fn test_delete_version ( archive_storage : bool ) -> Result < ( ) > {
360382 let env = TestEnvironment :: new ( ) . await ?;
361383 let storage = env. storage ( ) ?;
384+ let queue = env. build_queue ( ) ?;
362385
363386 async fn owners ( conn : & mut sqlx:: PgConnection , crate_id : CrateId ) -> Result < Vec < String > > {
364387 Ok ( sqlx:: query!(
@@ -387,6 +410,9 @@ mod tests {
387410 }
388411
389412 let mut conn = env. async_conn ( ) . await ?;
413+ queue. add_crate ( & KRATE , & V1 , 0 , None ) . await ?;
414+ queue. add_crate ( & KRATE , & V2 , 0 , None ) . await ?;
415+
390416 let v1 = env
391417 . fake_release ( )
392418 . await
@@ -400,6 +426,7 @@ mod tests {
400426 } )
401427 . create ( )
402428 . await ?;
429+ assert ! ( queue. has_build_queued( & KRATE , & V2 ) . await ?) ;
403430 assert ! ( release_exists( & mut conn, v1) . await ?) ;
404431 assert ! (
405432 storage
@@ -456,6 +483,8 @@ mod tests {
456483 ) ;
457484
458485 delete_version ( & mut conn, storage, & KRATE , & V1 ) . await ?;
486+ assert ! ( !queue. has_build_queued( & KRATE , & V1 ) . await ?) ;
487+ assert ! ( queue. has_build_queued( & KRATE , & V2 ) . await ?) ;
459488 assert ! ( !release_exists( & mut conn, v1) . await ?) ;
460489 if archive_storage {
461490 // for archive storage the archive and index files
0 commit comments