if failed to retrive content length, then print error
This commit is contained in:
parent
c7fff46ff3
commit
5637f62a8b
@ -71,7 +71,12 @@ pub async fn download_with_progress(
|
|||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.or(Err("Failed to connect server".to_owned()))?;
|
.or(Err("Failed to connect server".to_owned()))?;
|
||||||
let content_length = resp.content_length().unwrap();
|
let content_length = match resp.content_length() {
|
||||||
|
Some(k) => k,
|
||||||
|
None => {
|
||||||
|
panic!("Could not retrive content length from server. {:?}", &resp);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let pb = ProgressBar::new(content_length);
|
let pb = ProgressBar::new(content_length);
|
||||||
pb.set_style(ProgressStyle::with_template("{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})").unwrap()
|
pb.set_style(ProgressStyle::with_template("{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})").unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user