Fix download of non search inputs & .cargo config

This commit is contained in:
oSumAtrIX 2021-11-27 09:11:15 +01:00
parent f62db8e68d
commit bf0b8b2bad
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 56 additions and 53 deletions

2
.cargo/config Normal file
View file

@ -0,0 +1,2 @@
[net]
git-fetch-with-cli = true

View file

@ -143,60 +143,61 @@ async fn start() {
e e
) )
); );
} else { return;
let refresh = Duration::from_secs(settings.refresh_ui_seconds);
let now = Instant::now();
let mut time_elapsed: u64;
'outer: loop {
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
let mut exit_flag: i8 = 1;
for download in downloader.get_downloads().await {
let state = download.state;
let progress: String;
if state != DownloadState::Done {
exit_flag &= 0;
progress = match state {
DownloadState::Downloading(r, t) => {
let p = r as f32 / t as f32 * 100.0;
if p > 100.0 {
"100%".to_string()
} else {
format!("{}%", p as i8)
}
}
DownloadState::Post => "Postprocessing... ".to_string(),
DownloadState::None => "Preparing... ".to_string(),
DownloadState::Lock => "Preparing... ".to_string(),
DownloadState::Error(e) => {
exit_flag |= 1;
format!("{} ", e)
}
DownloadState::Done => {
exit_flag |= 1;
"Impossible state".to_string()
}
};
} else {
progress = "Done.".to_string();
}
println!("{:<19}| {}", progress, download.title);
}
time_elapsed = now.elapsed().as_secs();
if exit_flag == 1 {
break 'outer;
}
println!("\nElapsed second(s): {}", time_elapsed);
task::sleep(refresh).await
}
println!("Finished download(s) in {} second(s).", time_elapsed);
} }
} }
let refresh = Duration::from_secs(settings.refresh_ui_seconds);
let now = Instant::now();
let mut time_elapsed: u64;
'outer: loop {
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
let mut exit_flag: i8 = 1;
for download in downloader.get_downloads().await {
let state = download.state;
let progress: String;
if state != DownloadState::Done {
exit_flag &= 0;
progress = match state {
DownloadState::Downloading(r, t) => {
let p = r as f32 / t as f32 * 100.0;
if p > 100.0 {
"100%".to_string()
} else {
format!("{}%", p as i8)
}
}
DownloadState::Post => "Postprocessing... ".to_string(),
DownloadState::None => "Preparing... ".to_string(),
DownloadState::Lock => "Preparing... ".to_string(),
DownloadState::Error(e) => {
exit_flag |= 1;
format!("{} ", e)
}
DownloadState::Done => {
exit_flag |= 1;
"Impossible state".to_string()
}
};
} else {
progress = "Done.".to_string();
}
println!("{:<19}| {}", progress, download.title);
}
time_elapsed = now.elapsed().as_secs();
if exit_flag == 1 {
break 'outer;
}
println!("\nElapsed second(s): {}", time_elapsed);
task::sleep(refresh).await
}
println!("Finished download(s) in {} second(s).", time_elapsed);
} }
Err(e) => { Err(e) => {
error!("{} {}", "Handling input failed:".red(), e) error!("{} {}", "Handling input failed:".red(), e)