|
|
@ -79,7 +79,7 @@ fn download_command(backup: model::anime_boxes::Backup, mut config: config::Conf |
|
|
|
let filename = path_segments.last().unwrap();
|
|
|
|
let target_path = temp_directory.as_path().join(&filename);
|
|
|
|
|
|
|
|
let progress_count = format!("{}/{}", count, to_download_count);
|
|
|
|
let progress_count = format!("{:}/{:}", count, to_download_count);
|
|
|
|
let progress_filename = String::from(filename);
|
|
|
|
|
|
|
|
easy.url(url.as_str());
|
|
|
@ -89,13 +89,17 @@ fn download_command(backup: model::anime_boxes::Backup, mut config: config::Conf |
|
|
|
bytes_downloaded,
|
|
|
|
total_bytes_to_upload,
|
|
|
|
bytes_uploaded| {
|
|
|
|
let percentage = (bytes_downloaded / total_bytes_to_download) * 100.0;
|
|
|
|
let percentage = if bytes_downloaded <= 0.0 {
|
|
|
|
0.0
|
|
|
|
} else {
|
|
|
|
(bytes_downloaded / total_bytes_to_download) * 100.0
|
|
|
|
};
|
|
|
|
let mut stdout = stdout();
|
|
|
|
stdout.queue(cursor::SavePosition);
|
|
|
|
stdout.write(
|
|
|
|
format!(
|
|
|
|
"\n{} {}: {:.2}\n",
|
|
|
|
&progress_count, progress_filename, percentage
|
|
|
|
"{}: {:.2}% {}",
|
|
|
|
progress_filename, percentage, &progress_count
|
|
|
|
)
|
|
|
|
.as_bytes(),
|
|
|
|
);
|
|
|
@ -106,7 +110,7 @@ fn download_command(backup: model::anime_boxes::Backup, mut config: config::Conf |
|
|
|
);
|
|
|
|
match easy.write_function(move |data| match write_to_file(data, &target_path) {
|
|
|
|
Err(e) => {
|
|
|
|
println!("Error writing to {:#?}: {}%", target_path, e);
|
|
|
|
println!("Error writing to {:#?}: {}", target_path, e);
|
|
|
|
Err(WriteError::Pause)
|
|
|
|
}
|
|
|
|
Ok(d) => Ok(data.len()),
|
|
|
|