@@ -36,6 +36,7 @@ use crate::util::config::{Config, SslVersionConfig, SslVersionConfigRange};
36
36
use crate :: util:: errors:: CargoResult ;
37
37
use crate :: util:: important_paths:: find_root_manifest_for_wd;
38
38
use crate :: util:: { truncate_with_ellipsis, IntoUrl } ;
39
+ use crate :: util:: { Progress , ProgressStyle } ;
39
40
use crate :: { drop_print, drop_println, version} ;
40
41
41
42
/// Registry settings loaded from config files.
@@ -442,13 +443,26 @@ fn wait_for_publish(
442
443
) -> CargoResult < ( ) > {
443
444
let version_req = format ! ( "={}" , pkg. version( ) ) ;
444
445
let mut source = SourceConfigMap :: empty ( config) ?. load ( registry_src, & HashSet :: new ( ) ) ?;
445
- let source_description = source. describe ( ) ;
446
+ // Disable the source's built-in progress bars. Repeatedly showing a bunch
447
+ // of independent progress bars can be a little confusing. There is an
448
+ // overall progress bar managed here.
449
+ source. set_quiet ( true ) ;
450
+ let source_description = source. source_id ( ) . to_string ( ) ;
446
451
let query = Dependency :: parse ( pkg. name ( ) , Some ( & version_req) , registry_src) ?;
447
452
448
453
let now = std:: time:: Instant :: now ( ) ;
449
454
let sleep_time = std:: time:: Duration :: from_secs ( 1 ) ;
450
- let mut logged = false ;
451
- loop {
455
+ let max = timeout. as_secs ( ) as usize ;
456
+ config. shell ( ) . status ( "Published" , pkg. to_string ( ) ) ?;
457
+ // Short does not include the registry name.
458
+ let short_pkg_description = format ! ( "{} v{}" , pkg. name( ) , pkg. version( ) ) ;
459
+ config. shell ( ) . note ( format ! (
460
+ "Waiting up to {max} seconds for `{short_pkg_description}` to be available at {source_description}.\n \
461
+ You may press ctrl-c to skip waiting; the crate should be available shortly."
462
+ ) ) ?;
463
+ let mut progress = Progress :: with_style ( "Waiting" , ProgressStyle :: Ratio , config) ;
464
+ progress. tick_now ( 0 , max, "" ) ?;
465
+ let is_available = loop {
452
466
{
453
467
let _lock = config. acquire_package_cache_lock ( ) ?;
454
468
// Force re-fetching the source
@@ -470,31 +484,30 @@ fn wait_for_publish(
470
484
}
471
485
} ;
472
486
if !summaries. is_empty ( ) {
473
- break ;
487
+ break true ;
474
488
}
475
489
}
476
490
477
- if timeout < now. elapsed ( ) {
491
+ let elapsed = now. elapsed ( ) ;
492
+ if timeout < elapsed {
478
493
config. shell ( ) . warn ( format ! (
479
- "timed out waiting for `{}` to be in {}" ,
480
- pkg. name( ) ,
481
- source_description
494
+ "timed out waiting for `{short_pkg_description}` to be available in {source_description}" ,
482
495
) ) ?;
483
- break ;
484
- }
485
-
486
- if !logged {
487
- config. shell ( ) . status (
488
- "Waiting" ,
489
- format ! (
490
- "on `{}` to propagate to {} (ctrl-c to wait asynchronously)" ,
491
- pkg. name( ) ,
492
- source_description
493
- ) ,
496
+ config. shell ( ) . note (
497
+ "The registry may have a backlog that is delaying making the \
498
+ crate available. The crate should be available soon.",
494
499
) ?;
495
- logged = true ;
500
+ break false ;
496
501
}
502
+
503
+ progress. tick_now ( elapsed. as_secs ( ) as usize , max, "" ) ?;
497
504
std:: thread:: sleep ( sleep_time) ;
505
+ } ;
506
+ if is_available {
507
+ config. shell ( ) . status (
508
+ "Completed" ,
509
+ format ! ( "{pkg} has been successfully published to {source_description}" ) ,
510
+ ) ?;
498
511
}
499
512
500
513
Ok ( ( ) )
0 commit comments