On 10/24/2014 12:24 PM, Zac Medico wrote:
> From 5400ba6ecbccf946aa4d5a8ddaaa2e1d7b784d3f Mon Sep 17 00:00:00 2001
> From: David James <davidja...@google.com>
> Date: Thu, 23 Oct 2014 18:40:28 -0700
> Subject: [PATCH] If a binhost file sets a TTL header, honor it.

The first patch needs a small tweak to avoid an UnboundLocalError when
UseCachedCopyOfRemoteIndex is raised:

>From 9b31dff37f26b5114a6b2d9ad972b98947e43a53 Mon Sep 17 00:00:00 2001
From: David James <davidja...@google.com>
Date: Fri, 24 Oct 2014 12:40:30 -0700
Subject: [PATCH] Set "url" before marking the index as up to date.

Fixes UnboundLocalError: local variable 'url' referenced before
assignment.

BUG=chromium:381970
TEST=Run it locally.

Change-Id: I592bfcac4b27da6d95ae40f5f05bc31eb571702f
Reviewed-on: https://chromium-review.googlesource.com/225423
Tested-by: David James <davidja...@chromium.org>
Reviewed-by: Mike Frysinger <vap...@chromium.org>
---
 pym/portage/dbapi/bintree.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index e6eae33..844d015 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -886,16 +886,16 @@ class binarytree(object):
                        proc = None
                        tmp_filename = None
                        try:
-                               ttl = float(pkgindex.header.get("TTL", 0))
-                               if download_timestamp and ttl and 
download_timestamp + ttl > time.time():
-                                       raise UseCachedCopyOfRemoteIndex()
-
                                # urlparse.urljoin() only works correctly with 
recognized
                                # protocols and requires the base url to have a 
trailing
                                # slash, so join manually...
                                url = base_url.rstrip("/") + "/Packages"
                                f = None
 
+                               ttl = float(pkgindex.header.get("TTL", 0))
+                               if download_timestamp and ttl and 
download_timestamp + ttl > time.time():
+                                       raise UseCachedCopyOfRemoteIndex()
+
                                # Don't use urlopen for https, since it doesn't 
support
                                # certificate/hostname verification (bug 
#469888).
                                if parsed_url.scheme not in ('https',):
-- 
2.0.4

Reply via email to