From ad4300f54602c355c69b6477241f19eff038999f 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ramalama/http_client.py b/ramalama/http_client.py index c1496108..046b44f5 100644 --- a/ramalama/http_client.py +++ b/ramalama/http_client.py @@ -59,7 +59,7 @@ def perform_download(self, file, progress): while True: data = self.response.read(1024) if not data: - break + return size = file.write(data) if progress: @@ -69,8 +69,10 @@ def perform_download(self, file, progress): accumulated_size = 0 last_update_time = time.time() - if accumulated_size: + if accumulated_size > 0: self.update_progress(accumulated_size) + + if progress: print("\033[K", end="\r") def human_readable_time(self, seconds):