]> git.ipfire.org Git - pakfire.git/commitdiff
http: Reset the progressbar when download restarts
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Dec 2016 20:21:44 +0000 (21:21 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Dec 2016 20:21:44 +0000 (21:21 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/http.py
src/pakfire/ui/progressbar.py

index 2f4bb1c1c4f47c1308ff13058c01cc34ca5df142..39ea1f7e8295bd391c4fe47156483c2217c71f64 100644 (file)
@@ -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
index 143434b87a0f7c33715372a5bd8bd53325958791..8bd6e4b9b39478ace72392cf5d80e5bbfa60e9cc 100644 (file)
@@ -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