summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-11-03 09:54:33 -0500
committerDan McGee <dan@archlinux.org>2011-11-03 09:54:33 -0500
commit601c808b8d3d4eec76b215e56f1d56f4fe591367 (patch)
tree506d237dc4b466a083377997f854ad8e5e829d21 /src
parent1953fe43689054aded03eb166f4f987e7cc0dccd (diff)
downloadpacman-601c808b8d3d4eec76b215e56f1d56f4fe591367.tar.xz
Fix download progress rounding edge case
Allan's original message: Occasionally when the download rate showed 100.0 the output got messed up. This was caused by the rounding of a number between 99.95 and 100. Adjust the threshold to avoid this rounding issue. Dan: make this fix, but also show values between 0 and 9.995 with two decimal places since we have the room. Original-fix-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/callback.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 3ba07b0c..c7c16949 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -697,8 +697,11 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
xfered_human = humanize_size(xfered, '\0', &xfered_label);
printf(" %ls%-*s ", wcfname, padwid, "");
- /* We will show 1.6M/s, 11.6M/s, but 116K/s and 1116K/s */
- if(rate_human < 100.0) {
+ /* We will show 1.62M/s, 11.6M/s, but 116K/s and 1116K/s */
+ if(rate_human < 9.995) {
+ printf("%6.1f %3s %4.2f%c/s ",
+ xfered_human, xfered_label, rate_human, rate_label[0]);
+ } else if(rate_human < 99.95) {
printf("%6.1f %3s %4.1f%c/s ",
xfered_human, xfered_label, rate_human, rate_label[0]);
} else {