Compare commits

..

1 Commits

Author SHA1 Message Date
ef024cc8a8
feat: capture SIGINT to avoid corrupting downloads 2024-10-20 18:27:53 -04:00

View File

@ -187,11 +187,11 @@ async fn download_file(
let mut written = 0;
while let Some(img_chunk) = res.chunk().await.unwrap() {
if !running.load(Ordering::SeqCst) {
this_bar.abandon_with_message(format!(
"\x1b[37m[{i: >4}/{urls_amount}] \x1b[33mcancelling {img_url}\x1b[0m"
));
drop(file);
std::fs::remove_file(&file_path).unwrap();
this_bar.finish_with_message(format!(
"\x1b[37m[{i: >4}/{urls_amount}] \x1b[33mcancelled {img_url}\x1b[0m"
));
return;
}
file.write_all(&img_chunk).unwrap();