Add progress bar for multiple thread mode

This commit is contained in:
2022-06-20 04:28:32 +00:00
committed by GitHub
parent c233f0d1a4
commit a7df4ae112
2 changed files with 18 additions and 10 deletions

View File

@@ -467,7 +467,7 @@ impl<T: Write + Seek + Send + Sync + ClearFile + GetTargetFileName> 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],

View File

@@ -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?;
}