@@ -36,6 +36,7 @@ use crate::util::config::{Config, SslVersionConfig, SslVersionConfigRange};
3636use crate :: util:: errors:: CargoResult ;
3737use crate :: util:: important_paths:: find_root_manifest_for_wd;
3838use crate :: util:: { truncate_with_ellipsis, IntoUrl } ;
39+ use crate :: util:: { Progress , ProgressStyle } ;
3940use crate :: { drop_print, drop_println, version} ;
4041
4142/// Registry settings loaded from config files.
@@ -442,13 +443,26 @@ fn wait_for_publish(
442443) -> CargoResult < ( ) > {
443444 let version_req = format ! ( "={}" , pkg. version( ) ) ;
444445 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 ( ) ;
446451 let query = Dependency :: parse ( pkg. name ( ) , Some ( & version_req) , registry_src) ?;
447452
448453 let now = std:: time:: Instant :: now ( ) ;
449454 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 {
452466 {
453467 let _lock = config. acquire_package_cache_lock ( ) ?;
454468 // Force re-fetching the source
@@ -470,31 +484,30 @@ fn wait_for_publish(
470484 }
471485 } ;
472486 if !summaries. is_empty ( ) {
473- break ;
487+ break true ;
474488 }
475489 }
476490
477- if timeout < now. elapsed ( ) {
491+ let elapsed = now. elapsed ( ) ;
492+ if timeout < elapsed {
478493 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}" ,
482495 ) ) ?;
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.",
494499 ) ?;
495- logged = true ;
500+ break false ;
496501 }
502+
503+ progress. tick_now ( elapsed. as_secs ( ) as usize , max, "" ) ?;
497504 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+ ) ?;
498511 }
499512
500513 Ok ( ( ) )
0 commit comments