From 29561110c2c726bb336c54827e6ab78d3d94bf8a Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Sat, 8 Feb 2025 12:32:05 +0000 Subject: [PATCH] There would be one case where this wouldn't work When accumulated_size has just been refreshed to zero. Also check size is greater than zeor to avoid division by zero. Signed-off-by: Eric Curtin --- ramalama/http_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ramalama/http_client.py b/ramalama/http_client.py index c1496108..02073247 100644 --- a/ramalama/http_client.py +++ b/ramalama/http_client.py @@ -56,6 +56,7 @@ def perform_download(self, file, progress): self.start_time = time.time() accumulated_size = 0 last_update_time = time.time() + do_final_progress = False while True: data = self.response.read(1024) if not data: @@ -66,11 +67,14 @@ def perform_download(self, file, progress): accumulated_size += size if time.time() - last_update_time >= 0.1: self.update_progress(accumulated_size) + do_final_progress = True accumulated_size = 0 last_update_time = time.time() - if accumulated_size: - self.update_progress(accumulated_size) + if do_final_progress: + if accumulated_size: + self.update_progress(accumulated_size) + print("\033[K", end="\r") def human_readable_time(self, seconds):