@@ -22,6 +22,7 @@ pub struct DownloadProgressManager {
2222 multi_progress : Arc < MultiProgress > ,
2323 total_size : Arc < AtomicU64 > ,
2424 style : ProgressStyle ,
25+ cached_style : ProgressStyle ,
2526}
2627
2728impl DownloadProgressManager {
@@ -30,18 +31,29 @@ impl DownloadProgressManager {
3031 let multi_progress = Arc :: new ( MultiProgress :: new ( ) ) ;
3132
3233 let template = format ! (
33- "{{msg:<{width}}} [{{elapsed_precise}}] {{bar:60.white}} {{bytes}}/{{total_bytes}}" ,
34+ "{{msg:<{width}}} [{{elapsed_precise}}] {{bar:60.white}} {{bytes}}/{{total_bytes}} {{bytes_per_sec}} " ,
3435 width = max_filename_len
3536 ) ;
3637 let style = ProgressStyle :: default_bar ( )
3738 . template ( & template)
3839 . unwrap ( )
3940 . progress_chars ( "▇▆▅▄▃▂▁ " ) ;
4041
42+ // Cached file style without speed
43+ let cached_template = format ! (
44+ "{{msg:<{width}}} [{{elapsed_precise}}] {{bar:60.white}} {{bytes}}/{{total_bytes}}" ,
45+ width = max_filename_len
46+ ) ;
47+ let cached_style = ProgressStyle :: default_bar ( )
48+ . template ( & cached_template)
49+ . unwrap ( )
50+ . progress_chars ( "▇▆▅▄▃▂▁ " ) ;
51+
4152 Self {
4253 multi_progress,
4354 total_size : Arc :: new ( AtomicU64 :: new ( 0 ) ) ,
4455 style,
56+ cached_style,
4557 }
4658 }
4759
@@ -57,6 +69,18 @@ impl DownloadProgressManager {
5769 }
5870 }
5971
72+ /// Create a new progress bar for a cached file (no speed display)
73+ pub fn create_cached_file_progress ( & self , filename : & str ) -> FileProgress {
74+ let pb = self . multi_progress . add ( ProgressBar :: hidden ( ) ) ;
75+ pb. set_style ( self . cached_style . clone ( ) ) ;
76+ pb. set_message ( filename. to_string ( ) ) ;
77+
78+ FileProgress {
79+ pb,
80+ total_size : Arc :: clone ( & self . total_size ) ,
81+ }
82+ }
83+
6084 /// Get the total accumulated download size
6185 pub fn total_downloaded_bytes ( & self ) -> u64 {
6286 self . total_size . load ( Ordering :: Relaxed )
0 commit comments