[yum-commits] urlgrabber/grabber.py urlgrabber/progress.py
zpavlas at osuosl.org
zpavlas at osuosl.org
Fri Sep 27 11:10:35 UTC 2013
urlgrabber/grabber.py | 1 +
urlgrabber/progress.py | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
New commits:
commit 900b79ba46627650fc906acea4976a0875111e4f
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/grabber.py b/urlgrabber/grabber.py
index 63baef7..99c5b0b 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -1336,6 +1336,7 @@ class PyCurlFileObject(object):
location = ':'.join(buf.split(':')[1:])
location = location.strip()
self.scheme = urlparse.urlsplit(location)[0]
+ print 'updating', self.url, 'to', location
self.url = location
self._hdr_dump += buf
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