From: Michael Tremer Date: Wed, 7 Dec 2016 20:21:44 +0000 (+0100) Subject: http: Reset the progressbar when download restarts X-Git-Tag: 0.9.28~1285^2~1391 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bc8a7e4de200f7145787ef04ac608b3a78aaa25;p=pakfire.git http: Reset the progressbar when download restarts Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/http.py b/src/pakfire/http.py index 2f4bb1c1c..39ea1f7e8 100644 --- a/src/pakfire/http.py +++ b/src/pakfire/http.py @@ -289,6 +289,9 @@ class Client(object): try: with self._make_progressbar(message) as p: + # Reset the progressbar in case the download restarts + p.reset() + while True: with open(filename, "wb") as f: # Exclusively lock the file for download diff --git a/src/pakfire/ui/progressbar.py b/src/pakfire/ui/progressbar.py index 143434b87..8bd6e4b9b 100644 --- a/src/pakfire/ui/progressbar.py +++ b/src/pakfire/ui/progressbar.py @@ -57,6 +57,12 @@ class ProgressBar(object): def add(self, widget): self.widgets.append(widget) + def reset(self): + """ + Resets the progress bar to start + """ + self.start() + def start(self): self.num_intervals = max(self.term_width, 100) self.next_update = 0