diff --git a/src/downloader/downloader.rs b/src/downloader/downloader.rs index e1dcd9f..606fc0a 100644 --- a/src/downloader/downloader.rs +++ b/src/downloader/downloader.rs @@ -467,7 +467,7 @@ impl DownloaderIn /// Write datas to the file. /// * `data` - Data /// * `pd` - The status of the writed part - /// * + /// * `index` - The index of the writed part pub fn write_part( &self, data: &[u8], diff --git a/src/downloader/tasks.rs b/src/downloader/tasks.rs index ca1ed1a..b4e6342 100644 --- a/src/downloader/tasks.rs +++ b/src/downloader/tasks.rs @@ -169,18 +169,23 @@ pub async fn create_download_tasks_multi_first< return Err(DownloaderError::from(status)); } match result.content_length() { - Some(len) => match d.pd.set_file_size(len) { - Ok(_) => { - #[cfg(test)] - { - println!("Set the file size to {}", len); - println!("Is downloading: {}", d.pd.is_downloading()); + Some(len) => { + match d.pd.set_file_size(len) { + Ok(_) => { + #[cfg(test)] + { + println!("Set the file size to {}", len); + println!("Is downloading: {}", d.pd.is_downloading()); + } + } + Err(e) => { + println!("{}", e) } } - Err(e) => { - println!("{}", e) + if d.enabled_progress_bar() { + d.set_progress_bar_length(len); } - }, + } None => { d.fallback_to_simp(); return Err(DownloaderError::from(gettext( @@ -467,6 +472,9 @@ pub async fn check_tasks< d.add_task(task); } } else { + if d.enabled_progress_bar() { + d.set_progress_bar_position(d.pd.get_downloaded_file_size()); + } if d.tasks.get_ref().len() < (d.max_threads.qload() as usize) { add_new_multi_tasks(&d).await?; }