[pacman-dev] [PATCH 2/2] pacman: clap transfer rate to >=0

morganamilo morganamilo at archlinux.org
Sat Jan 16 16:32:17 UTC 2021


Sometimes when downloading packages the transfer rate drops in to the
negative. Not only is this incorrect, but it messes with the allignment
of the progress bars. So lets make sure it's always >= 0.

---

This may not be the best fix as it does not address the root issue.
But I have no idea what the root issue is so it's on somebody else to
fix that.
---
 src/pacman/callback.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 279338e7..15317220 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -851,6 +851,10 @@ static void draw_pacman_progress_bar(struct pacman_progress_bar *bar)
 	rate_human = humanize_size((off_t)bar->rate, '\0', -1, &rate_label);
 	xfered_human = humanize_size(bar->sync_xfered, '\0', -1, &xfered_label);
 
+	if(rate_human < 0) {
+		rate_human = 0;
+	}
+
 	printf(" %ls%-*s ", wcfname, padwid, "");
 	/* We will show 1.62 MiB/s, 11.6 MiB/s, but 116 KiB/s and 1116 KiB/s */
 	if(rate_human < 9.995) {
-- 
2.30.0


More information about the pacman-dev mailing list