@@ -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 {
@@ -223,23 +234,6 @@ pub(crate) struct DownloadStatus {
223234}
224235
225236impl DownloadStatus {
226- fn new ( component : impl Into < Cow < ' static , str > > ) -> Self {
227- let progress = ProgressBar :: hidden ( ) ;
228- progress. set_style (
229- ProgressStyle :: with_template (
230- "{msg:>12.bold} [{bar:40}] {bytes}/{total_bytes} ({bytes_per_sec}, ETA: {eta})" ,
231- )
232- . unwrap ( )
233- . progress_chars ( "## " ) ,
234- ) ;
235- progress. set_message ( component) ;
236-
237- Self {
238- progress,
239- retry_time : Mutex :: new ( None ) ,
240- }
241- }
242-
243237 pub ( crate ) fn received_length ( & self , len : u64 ) {
244238 self . progress . reset ( ) ;
245239 self . progress . set_length ( len) ;
0 commit comments