lib: Use greentext to signify send_image progress

not to be confused with 4chan memes

Signed-off-by: Konrad Dybcio <konradybcio@kernel.org>
This commit is contained in:
Konrad Dybcio
2024-05-07 01:44:55 +02:00
committed by Konrad Dybcio
parent 143159b868
commit 5bf2dcc137

View File

@@ -1,3 +1,4 @@
use colored::Colorize;
use serde::{Deserialize, Serialize};
use std::io::{stdout, Write};
use std::mem::size_of;
@@ -109,13 +110,20 @@ pub async fn send_image(write_sink: &mut Arc<Mutex<impl Write>>, buf: &[u8]) ->
let percent_done = 100 * bytes_sent / buf.len();
if percent_done != last_percent_done {
write!(stdout(), " Sending image: {}%\r", percent_done).unwrap();
let s = format!(" Sending image: {}%\r", percent_done);
write!(stdout(), "{}", s.green()).unwrap();
stdout().flush()?;
}
send_msg(write_sink, Sk8brdMsgs::MsgFastbootDownload, chunk).await?;
bytes_sent += chunk.len();
last_percent_done = percent_done;
if bytes_sent == buf.len() {
write!(stdout(), "\r{}\r", " ".repeat(80))?;
write!(stdout(), "{}\r\n", String::from("Image sent!").green())?;
}
}
send_ack(write_sink, Sk8brdMsgs::MsgFastbootDownload).await