Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] Re: [PATCH] If a binhost file sets a TTL header, honor it.
Date: Fri, 24 Oct 2014 21:15:33
Message-Id: 544AC171.70503@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] If a binhost file sets a TTL header, honor it. by Zac Medico
1 On 10/24/2014 12:24 PM, Zac Medico wrote:
2 > From 5400ba6ecbccf946aa4d5a8ddaaa2e1d7b784d3f Mon Sep 17 00:00:00 2001
3 > From: David James <davidjames@××××××.com>
4 > Date: Thu, 23 Oct 2014 18:40:28 -0700
5 > Subject: [PATCH] If a binhost file sets a TTL header, honor it.
6
7 The first patch needs a small tweak to avoid an UnboundLocalError when
8 UseCachedCopyOfRemoteIndex is raised:
9
10 From 9b31dff37f26b5114a6b2d9ad972b98947e43a53 Mon Sep 17 00:00:00 2001
11 From: David James <davidjames@××××××.com>
12 Date: Fri, 24 Oct 2014 12:40:30 -0700
13 Subject: [PATCH] Set "url" before marking the index as up to date.
14
15 Fixes UnboundLocalError: local variable 'url' referenced before
16 assignment.
17
18 BUG=chromium:381970
19 TEST=Run it locally.
20
21 Change-Id: I592bfcac4b27da6d95ae40f5f05bc31eb571702f
22 Reviewed-on: https://chromium-review.googlesource.com/225423
23 Tested-by: David James <davidjames@××××××××.org>
24 Reviewed-by: Mike Frysinger <vapier@××××××××.org>
25 ---
26 pym/portage/dbapi/bintree.py | 8 ++++----
27 1 file changed, 4 insertions(+), 4 deletions(-)
28
29 diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
30 index e6eae33..844d015 100644
31 --- a/pym/portage/dbapi/bintree.py
32 +++ b/pym/portage/dbapi/bintree.py
33 @@ -886,16 +886,16 @@ class binarytree(object):
34 proc = None
35 tmp_filename = None
36 try:
37 - ttl = float(pkgindex.header.get("TTL", 0))
38 - if download_timestamp and ttl and download_timestamp + ttl > time.time():
39 - raise UseCachedCopyOfRemoteIndex()
40 -
41 # urlparse.urljoin() only works correctly with recognized
42 # protocols and requires the base url to have a trailing
43 # slash, so join manually...
44 url = base_url.rstrip("/") + "/Packages"
45 f = None
46
47 + ttl = float(pkgindex.header.get("TTL", 0))
48 + if download_timestamp and ttl and download_timestamp + ttl > time.time():
49 + raise UseCachedCopyOfRemoteIndex()
50 +
51 # Don't use urlopen for https, since it doesn't support
52 # certificate/hostname verification (bug #469888).
53 if parsed_url.scheme not in ('https',):
54 --
55 2.0.4

Replies