[yum-commits] urlgrabber/progress.py

zpavlas at osuosl.org zpavlas at osuosl.org
Fri Sep 27 11:43:11 UTC 2013


Rebased ref, commits from common ancestor:
commit 0c03f8b2cf19de59f913279b17b19661daa4d34a
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Fri Sep 27 13:07:37 2013 +0200

    Never display negative downloading speed. BZ 1001767

diff --git a/urlgrabber/progress.py b/urlgrabber/progress.py
index b456a0c..5d148f0 100644
--- a/urlgrabber/progress.py
+++ b/urlgrabber/progress.py
@@ -646,10 +646,14 @@ class RateEstimator:
         
     def update(self, amount_read, now=None):
         if now is None: now = time.time()
-        if amount_read == 0:
+        # libcurl calls the progress callback when fetching headers
+        # too, thus amount_read = 0 .. hdr_size .. 0 .. content_size.
+        # Ocassionally we miss the 2nd zero and report avg speed < 0.
+        # Handle read_diff < 0 here. BZ 1001767.
+        if amount_read == 0 or amount_read < self.last_amount_read:
             # if we just started this file, all bets are off
             self.last_update_time = now
-            self.last_amount_read = 0
+            self.last_amount_read = amount_read
             self.ave_rate = None
             return
 


More information about the Yum-commits mailing list