Attempted to add speed indicator on both sender and receiver (untested)

This commit is contained in:
amatgil 2022-10-03 00:56:32 +02:00
parent f5caf49c92
commit 93d5806e49

View file

@ -411,7 +411,8 @@ pub fn sender<F: Fn(f32)>(args: &Vec<String>, on_progress: F) {
sc.write_safe(&buf[..read]).expect("send error");
bytes_sent += read as u64;
if (bytes_sent % (br * 20) as u64) < (br as u64) {
print!("\r\x1b[KSent {} bytes", bytes_sent);
print!("\r\x1b[KSent {} bytes; Speed: {} kb/s",
bytes_sent, (read / 1000) / last_update as usize );
stdout().flush().unwrap();
}
if unix_millis() - last_update > 100 {
@ -478,7 +479,8 @@ pub fn receiver<F: Fn(f32)>(args: &Vec<String>, on_progress: F) {
file.flush().expect("file flush error");
bytes_received += amount as u64;
if (bytes_received % (br * 20) as u64) < (br as u64) {
print!("\r\x1b[KReceived {} bytes", bytes_received);
print!("\r\x1b[KSent {} bytes; Speed: {} kb/s",
bytes_sent, (read / 1000) / last_update as usize );
stdout().flush().unwrap();
}
if unix_millis() - last_update > 100 {