Skip to content

Commit

Permalink
Stop showing ETA after download is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed May 15, 2024
1 parent 9caf4fc commit d25d510
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ impl DownloadTracker {
(remaining / speed) as u64
});
format!(
"{} / {} ({:3.0} %) {} in {} ETA: {}",
"{} / {} ({:3.0} %) {} in {}{}",
total_h,
content_len_h,
percent,
speed_h,
elapsed_h.display(),
eta_h.display(),
Eta(eta_h),
)
}
None => format!(
Expand Down Expand Up @@ -220,6 +220,17 @@ impl DownloadTracker {
}
}

struct Eta(Duration);

impl fmt::Display for Eta {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
Duration::ZERO => Ok(()),
_ => write!(f, "{}", self.0.display()),
}
}
}

trait DurationDisplay {
fn display(self) -> Display;
}
Expand Down

0 comments on commit d25d510

Please sign in to comment.