summaryrefslogtreecommitdiff
path: root/urlgrabber
diff options
context:
space:
mode:
authorZdenek Pavlas <zpavlas@redhat.com>2013-10-01 15:25:05 +0200
committerZdenek Pavlas <zpavlas@redhat.com>2013-10-01 15:28:25 +0200
commitf2a33c7c2fef7a8266e3a5753e3ae573b873264e (patch)
tree0f20e293f636f9a3758bb5122d272c6f20a89cce /urlgrabber
parent0c03f8b2cf19de59f913279b17b19661daa4d34a (diff)
downloadurlgrabber-f2a33c7c2fef7a8266e3a5753e3ae573b873264e.tar.gz
clamp timestamps from the future. BZ 894630, 1013733
The previous fix was incomplete. Only update() path was fixed, but not the estimate() path. By moving the code that clamps timestamps to the loader, we fix both.
Diffstat (limited to 'urlgrabber')
-rw-r--r--urlgrabber/grabber.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index 63baef7..9252977 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -2355,9 +2355,10 @@ class _TH:
filename = default_grabber.opts.timedhosts
if filename and _TH.dirty is None:
try:
+ now = int(time.time())
for line in open(filename):
host, speed, fail, ts = line.rsplit(' ', 3)
- _TH.hosts[host] = int(speed), int(fail), int(ts)
+ _TH.hosts[host] = int(speed), int(fail), min(int(ts), now)
except IOError: pass
_TH.dirty = False
@@ -2389,9 +2390,6 @@ class _TH:
if ug_err is None:
# defer first update if the file was small. BZ 851178.
if not ts and dl_size < 1e6: return
- # clamp timestamps from the future. BZ 894630.
- if ts > now: ts = now
-
# k1: the older, the less useful
# k2: <500ms readings are less reliable
# speeds vary, use 10:1 smoothing