@@ -9,6 +9,7 @@ use serde::{Deserialize, Serialize};
9
9
use std:: collections:: { BTreeMap , BTreeSet , HashMap , HashSet } ;
10
10
use std:: fmt:: Write as _;
11
11
use std:: io:: { Read , Write } ;
12
+ use std:: task:: Poll ;
12
13
13
14
pub const REPORT_PREAMBLE : & str = "\
14
15
The following warnings were discovered during the build. These warnings are an
@@ -264,7 +265,7 @@ fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<
264
265
let _lock = ws. config ( ) . acquire_package_cache_lock ( ) . ok ( ) ?;
265
266
// Create a set of updated registry sources.
266
267
let map = SourceConfigMap :: new ( ws. config ( ) ) . ok ( ) ?;
267
- let package_ids: BTreeSet < _ > = package_ids
268
+ let mut package_ids: BTreeSet < _ > = package_ids
268
269
. iter ( )
269
270
. filter ( |pkg_id| pkg_id. source_id ( ) . is_registry ( ) )
270
271
. collect ( ) ;
@@ -279,15 +280,35 @@ fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet<PackageId>) -> Option<
279
280
Some ( ( sid, source) )
280
281
} )
281
282
. collect ( ) ;
282
- // Query the sources for new versions.
283
+
284
+ // Query the sources for available versions, mapping `package_ids` into `summaries`.
285
+ let mut summaries = Vec :: new ( ) ;
286
+ while !package_ids. is_empty ( ) {
287
+ package_ids. retain ( |& pkg_id| {
288
+ let source = match sources. get_mut ( & pkg_id. source_id ( ) ) {
289
+ Some ( s) => s,
290
+ None => return false ,
291
+ } ;
292
+ let dep = match Dependency :: parse ( pkg_id. name ( ) , None , pkg_id. source_id ( ) ) {
293
+ Ok ( dep) => dep,
294
+ Err ( _) => return false ,
295
+ } ;
296
+ match source. query_vec ( & dep) {
297
+ Poll :: Ready ( Ok ( sum) ) => {
298
+ summaries. push ( ( pkg_id, sum) ) ;
299
+ false
300
+ }
301
+ Poll :: Ready ( Err ( _) ) => false ,
302
+ Poll :: Pending => true ,
303
+ }
304
+ } ) ;
305
+ for ( _, source) in sources. iter_mut ( ) {
306
+ source. block_until_ready ( ) . ok ( ) ?;
307
+ }
308
+ }
309
+
283
310
let mut updates = String :: new ( ) ;
284
- for pkg_id in package_ids {
285
- let source = match sources. get_mut ( & pkg_id. source_id ( ) ) {
286
- Some ( s) => s,
287
- None => continue ,
288
- } ;
289
- let dep = Dependency :: parse ( pkg_id. name ( ) , None , pkg_id. source_id ( ) ) . ok ( ) ?;
290
- let summaries = source. query_vec ( & dep) . ok ( ) ?;
311
+ for ( pkg_id, summaries) in summaries {
291
312
let mut updated_versions: Vec < _ > = summaries
292
313
. iter ( )
293
314
. map ( |summary| summary. version ( ) )
0 commit comments