@@ -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
@@ -189,6 +189,24 @@ impl<'a> DownloadCfg<'a> {
189189
190190 Ok ( Some ( ( file, partial_hash) ) )
191191 }
192+
193+ pub ( crate ) fn status_for ( & self , component : impl Into < Cow < ' static , str > > ) -> DownloadStatus {
194+ let progress = ProgressBar :: hidden ( ) ;
195+ progress. set_style (
196+ ProgressStyle :: with_template (
197+ "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})" ,
198+ )
199+ . unwrap ( )
200+ . progress_chars ( "## " ) ,
201+ ) ;
202+ progress. set_message ( component) ;
203+ self . tracker . multi_progress_bars . add ( progress. clone ( ) ) ;
204+
205+ DownloadStatus {
206+ progress,
207+ retry_time : Mutex :: new ( None ) ,
208+ }
209+ }
192210}
193211
194212/// Tracks download progress and displays information about it to a terminal.
@@ -213,13 +231,6 @@ impl DownloadTracker {
213231 multi_progress_bars,
214232 }
215233 }
216-
217- /// Creates a new ProgressBar for the given component.
218- pub ( crate ) fn status_for ( & self , component : impl Into < Cow < ' static , str > > ) -> DownloadStatus {
219- let status = DownloadStatus :: new ( component) ;
220- self . multi_progress_bars . add ( status. progress . clone ( ) ) ;
221- status
222- }
223234}
224235
225236pub ( crate ) struct DownloadStatus {
@@ -234,23 +245,6 @@ pub(crate) struct DownloadStatus {
234245}
235246
236247impl DownloadStatus {
237- fn new ( component : impl Into < Cow < ' static , str > > ) -> Self {
238- let progress = ProgressBar :: hidden ( ) ;
239- progress. set_style (
240- ProgressStyle :: with_template (
241- "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})" ,
242- )
243- . unwrap ( )
244- . progress_chars ( "## " ) ,
245- ) ;
246- progress. set_message ( component) ;
247-
248- Self {
249- progress,
250- retry_time : Mutex :: new ( None ) ,
251- }
252- }
253-
254248 pub ( crate ) fn received_length ( & self , len : u64 ) {
255249 self . progress . reset ( ) ;
256250 self . progress . set_length ( len) ;
0 commit comments