From 629228d3658056f12d3367a05e4d051948425aa1 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sat, 13 Aug 2022 17:37:57 +0200 Subject: [PATCH] better progress display --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f54284..ad923ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "qft" -version = "0.1.5" +version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index 6093baf..d979114 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qft" -version = "0.1.5" +version = "0.1.6" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 5c9ecc0..9537340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::{ collections::HashMap, fs::File, - io::{Error, Read, Write}, + io::{Error, Read, Write, stdout}, net::*, str::FromStr, thread, @@ -256,7 +256,10 @@ fn sender(args: &Vec) { sc.write_safe(&buf[..read]).expect("send error"); bytes_sent += read as u64; - print!("\rSent {} bytes", bytes_sent); + if (bytes_sent % (br * 20) as u64) < (br as u64) { + print!("\rSent {} bytes", bytes_sent); + stdout().flush().unwrap(); + } } } @@ -285,7 +288,10 @@ fn receiver(args: &Vec) { file.write(buf).expect("write error"); bytes_received += len as u64; - print!("\rReceived {} bytes", bytes_received); + if (bytes_received % (br * 20) as u64) < (br as u64) { + print!("\rReceived {} bytes", bytes_received); + stdout().flush().unwrap(); + } } }