@@ -15,7 +15,8 @@ use semver::{Version, VersionReq};
1515use std:: env;
1616use std:: io:: Write ;
1717use std:: sync:: LazyLock ;
18- use tracing:: { debug, instrument, warn, Span } ;
18+ use tracing:: { debug, instrument, warn} ;
19+ #[ cfg( feature = "indicatif" ) ]
1920use tracing_indicatif:: span_ext:: IndicatifSpanExt ;
2021
2122static USER_AGENT : LazyLock < String > = LazyLock :: new ( || {
@@ -132,13 +133,18 @@ impl Repository for Maven {
132133 debug ! ( "Downloading archive {archive_url}" ) ;
133134 let request = client. get ( & archive_url) ;
134135 let response = request. send ( ) . await ?. error_for_status ( ) ?;
135- let span = Span :: current ( ) ;
136- let content_length = response. content_length ( ) . unwrap_or_default ( ) ;
136+ #[ cfg( feature = "indicatif" ) ]
137+ let span = tracing:: Span :: current ( ) ;
138+ #[ cfg( feature = "indicatif" ) ]
139+ {
140+ let content_length = response. content_length ( ) . unwrap_or_default ( ) ;
141+ span. pb_set_length ( content_length) ;
142+ }
137143 let mut bytes = Vec :: new ( ) ;
138144 let mut source = response. bytes_stream ( ) ;
139- span. pb_set_length ( content_length) ;
140145 while let Some ( chunk) = source. next ( ) . await {
141146 bytes. write_all ( & chunk?) ?;
147+ #[ cfg( feature = "indicatif" ) ]
142148 span. pb_set_position ( bytes. len ( ) as u64 ) ;
143149 }
144150 debug ! ( "Archive {archive_url} downloaded: {}" , bytes. len( ) , ) ;
0 commit comments