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 <davidjames@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
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 @@
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',):