Added error handling to upload subcommand

This commit is contained in:
JandereDev 2021-09-28 15:55:08 +02:00 committed by Ben Schattinger
parent a08eb0b791
commit fd6d7d87b6

View file

@ -106,11 +106,19 @@ pub fn run() -> bool {
if dest.ends_with('/') { if dest.ends_with('/') {
dest.remove(dest.len() - 1); dest.remove(dest.len() - 1);
} }
handle let res = handle
.write_file(&format!("{}/{}", dest, name), &buf, &mut |remaining| { .write_file(&format!("{}/{}", dest, name), &buf, &mut |remaining| {
bar.set_position((buf.len() - remaining) as u64) bar.set_position((buf.len() - remaining) as u64)
}) });
.unwrap();
match res {
Ok(_) => {
println!("Upload {}: Ok", dest);
}
Err(error) => {
bar.abandon_with_message(&format!("Failed: {}", error));
}
}
bar.finish(); bar.finish();
} }
} else { } else {