Skip to content

Commit 7e3f7d6

Browse files
committed
fix: remove unnecessary progress tick rate limiting
1 parent d58aa8a commit 7e3f7d6

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/cargo/sources/git/utils.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ pub fn with_fetch_options(
696696
network::with_retry(config, || {
697697
with_authentication(url, git_config, |f| {
698698
let mut last_recv = 0.0; // in Byte
699-
let mut last_rate = 0.0; // in Byte/s
700699
let mut last_update = Instant::now();
701700
let mut rcb = git2::RemoteCallbacks::new();
702701
rcb.credentials(f);
@@ -708,24 +707,20 @@ pub fn with_fetch_options(
708707
} else {
709708
// Receiving objects.
710709
let duration = last_update.elapsed();
711-
let (recv, rate) = if duration > Duration::from_secs(1) {
712-
let recv = stats.received_bytes() as f32;
713-
let rate = (recv - last_recv) / duration.as_secs_f32();
710+
let recv = stats.received_bytes() as f32;
711+
let rate = (recv - last_recv) / duration.as_secs_f32();
712+
if duration > Duration::from_secs(3) {
714713
last_recv = recv;
715-
last_rate = rate;
716714
last_update = Instant::now();
717-
(recv, rate)
718-
} else {
719-
(last_recv, last_rate)
720-
};
715+
}
721716
fn format_bytes(bytes: f32) -> (&'static str, f32) {
722717
static UNITS: [&str; 5] = ["", "K", "M", "G", "T"];
723718
let i = (bytes.log2() / 10.0).min(4.0) as usize;
724719
(UNITS[i], bytes / 1024_f32.powi(i as i32))
725720
}
726721
let (rate_unit, rate) = format_bytes(rate);
727722
let (unit, recv) = format_bytes(recv);
728-
format!(" | {:.2}{}iB | {:.2}{}iB/s", recv, unit, rate, rate_unit)
723+
format!(", {:.2}{}iB | {:.2}{}iB/s", recv, unit, rate, rate_unit)
729724
};
730725
progress
731726
.tick(stats.indexed_objects(), stats.total_objects(), &msg)

0 commit comments

Comments
 (0)