Fix download of non search inputs & .cargo config
This commit is contained in:
parent
f62db8e68d
commit
bf0b8b2bad
2 changed files with 56 additions and 53 deletions
2
.cargo/config
Normal file
2
.cargo/config
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[net]
|
||||
git-fetch-with-cli = true
|
||||
105
src/main.rs
105
src/main.rs
|
|
@ -143,60 +143,61 @@ async fn start() {
|
|||
e
|
||||
)
|
||||
);
|
||||
} else {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("{} {}", "Handling input failed:".red(), e)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue