@@ -10,8 +10,6 @@ use diesel::expression::SqlLiteral;
1010use diesel:: prelude:: * ;
1111use diesel:: sql_types:: { Array , BigInt , Text } ;
1212use diesel_async:: RunQueryDsl ;
13- use futures_util:: TryStreamExt ;
14- use std:: collections:: HashMap ;
1513use std:: fmt:: Display ;
1614
1715#[ derive( clap:: Parser , Debug ) ]
@@ -42,19 +40,14 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
4240 . inner_join ( crate_downloads:: table)
4341 . filter ( crates:: name. eq_any ( & crate_names) )
4442 . select ( CrateInfo :: as_select ( ) )
45- . load_stream :: < CrateInfo > ( & mut conn)
43+ . load :: < CrateInfo > ( & mut conn)
4644 . await
47- . context ( "Failed to look up crate name from the database" ) ?
48- . try_fold ( HashMap :: new ( ) , |mut map, info| {
49- map. insert ( info. name . clone ( ) , info) ;
50- futures_util:: future:: ready ( Ok ( map) )
51- } )
52- . await ?;
45+ . context ( "Failed to look up crate name from the database" ) ?;
5346
5447 println ! ( "Deleting the following crates:" ) ;
5548 println ! ( ) ;
5649 for name in & crate_names {
57- match existing_crates. get ( name) {
50+ match existing_crates. iter ( ) . find ( |info| info . name == * name) {
5851 Some ( info) => println ! ( " - {} ({info})" , name. bold( ) ) ,
5952 None => println ! ( " - {name} (⚠️ crate not found)" ) ,
6053 }
@@ -68,7 +61,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
6861 }
6962
7063 for name in & crate_names {
71- if let Some ( crate_info) = existing_crates. get ( name) {
64+ if let Some ( crate_info) = existing_crates. iter ( ) . find ( |info| info . name == * name) {
7265 let id = crate_info. id ;
7366
7467 info ! ( "{name}: Deleting crate from the database…" ) ;
0 commit comments