@@ -9,7 +9,6 @@ use std::rc::Rc;
9
9
use std:: time:: { Duration , Instant } ;
10
10
11
11
use anyhow:: Context as _;
12
- use bytesize:: ByteSize ;
13
12
use cargo_util_schemas:: manifest:: RustVersion ;
14
13
use curl:: easy:: Easy ;
15
14
use curl:: multi:: { EasyHandle , Multi } ;
@@ -35,6 +34,7 @@ use crate::util::network::http::http_handle_and_timeout;
35
34
use crate :: util:: network:: http:: HttpTimeout ;
36
35
use crate :: util:: network:: retry:: { Retry , RetryResult } ;
37
36
use crate :: util:: network:: sleep:: SleepTracker ;
37
+ use crate :: util:: HumanBytes ;
38
38
use crate :: util:: { self , internal, GlobalContext , Progress , ProgressStyle } ;
39
39
40
40
/// Information about a package that is available somewhere in the file system.
@@ -914,7 +914,8 @@ impl<'a, 'gctx> Downloads<'a, 'gctx> {
914
914
// have a great view into the progress of the extraction. Let's prepare
915
915
// the user for this CPU-heavy step if it looks like it'll take some
916
916
// time to do so.
917
- if dl. total . get ( ) < ByteSize :: kb ( 400 ) . 0 {
917
+ let kib_400 = 1024 * 400 ;
918
+ if dl. total . get ( ) < kib_400 {
918
919
self . tick ( WhyTick :: DownloadFinished ) ?;
919
920
} else {
920
921
self . tick ( WhyTick :: Extracting ( & dl. id . name ( ) ) ) ?;
@@ -1113,7 +1114,7 @@ impl<'a, 'gctx> Downloads<'a, 'gctx> {
1113
1114
}
1114
1115
}
1115
1116
if remaining > 0 && dur > Duration :: from_millis ( 500 ) {
1116
- msg. push_str ( & format ! ( ", remaining bytes: {}" , ByteSize ( remaining) ) ) ;
1117
+ msg. push_str ( & format ! ( ", remaining bytes: {:.1 }" , HumanBytes ( remaining) ) ) ;
1117
1118
}
1118
1119
}
1119
1120
}
@@ -1153,20 +1154,21 @@ impl<'a, 'gctx> Drop for Downloads<'a, 'gctx> {
1153
1154
"crates"
1154
1155
} ;
1155
1156
let mut status = format ! (
1156
- "{} {} ({}) in {}" ,
1157
+ "{} {} ({:.1 }) in {}" ,
1157
1158
self . downloads_finished,
1158
1159
crate_string,
1159
- ByteSize ( self . downloaded_bytes) ,
1160
+ HumanBytes ( self . downloaded_bytes) ,
1160
1161
util:: elapsed( self . start. elapsed( ) )
1161
1162
) ;
1162
1163
// print the size of largest crate if it was >1mb
1163
1164
// however don't print if only a single crate was downloaded
1164
1165
// because it is obvious that it will be the largest then
1165
- if self . largest . 0 > ByteSize :: mb ( 1 ) . 0 && self . downloads_finished > 1 {
1166
+ let mib_1 = 1024 * 1024 ;
1167
+ if self . largest . 0 > mib_1 && self . downloads_finished > 1 {
1166
1168
status. push_str ( & format ! (
1167
- " (largest was `{}` at {})" ,
1169
+ " (largest was `{}` at {:.1 })" ,
1168
1170
self . largest. 1 ,
1169
- ByteSize ( self . largest. 0 ) ,
1171
+ HumanBytes ( self . largest. 0 ) ,
1170
1172
) ) ;
1171
1173
}
1172
1174
// Clear progress before displaying final summary.
0 commit comments