@@ -23,7 +23,7 @@ const UPDATE_HASH_LEN: usize = 20;
2323pub struct DownloadCfg < ' a > {
2424 pub tmp_cx : & ' a temp:: Context ,
2525 pub download_dir : & ' a PathBuf ,
26- pub ( crate ) tracker : DownloadTracker ,
26+ pub ( super ) tracker : DownloadTracker ,
2727 pub process : & ' a Process ,
2828}
2929
@@ -184,6 +184,24 @@ impl<'a> DownloadCfg<'a> {
184184
185185 Ok ( Some ( ( file, partial_hash) ) )
186186 }
187+
188+ pub ( crate ) fn status_for ( & self , component : impl Into < Cow < ' static , str > > ) -> DownloadStatus {
189+ let progress = ProgressBar :: hidden ( ) ;
190+ progress. set_style (
191+ ProgressStyle :: with_template (
192+ "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})" ,
193+ )
194+ . unwrap ( )
195+ . progress_chars ( "## " ) ,
196+ ) ;
197+ progress. set_message ( component) ;
198+ self . tracker . multi_progress_bars . add ( progress. clone ( ) ) ;
199+
200+ DownloadStatus {
201+ progress,
202+ retry_time : Mutex :: new ( None ) ,
203+ }
204+ }
187205}
188206
189207/// Tracks download progress and displays information about it to a terminal.
@@ -208,13 +226,6 @@ impl DownloadTracker {
208226 multi_progress_bars,
209227 }
210228 }
211-
212- /// Creates a new ProgressBar for the given component.
213- pub ( crate ) fn status_for ( & self , component : impl Into < Cow < ' static , str > > ) -> DownloadStatus {
214- let status = DownloadStatus :: new ( component) ;
215- self . multi_progress_bars . add ( status. progress . clone ( ) ) ;
216- status
217- }
218229}
219230
220231pub ( crate ) struct DownloadStatus {
@@ -229,23 +240,6 @@ pub(crate) struct DownloadStatus {
229240}
230241
231242impl DownloadStatus {
232- fn new ( component : impl Into < Cow < ' static , str > > ) -> Self {
233- let progress = ProgressBar :: hidden ( ) ;
234- progress. set_style (
235- ProgressStyle :: with_template (
236- "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})" ,
237- )
238- . unwrap ( )
239- . progress_chars ( "## " ) ,
240- ) ;
241- progress. set_message ( component) ;
242-
243- Self {
244- progress,
245- retry_time : Mutex :: new ( None ) ,
246- }
247- }
248-
249243 pub ( crate ) fn received_length ( & self , len : u64 ) {
250244 self . progress . reset ( ) ;
251245 self . progress . set_length ( len) ;
0 commit comments