summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-07-18 22:07:42 -0700
committerZac Medico <zmedico@gentoo.org>2010-07-18 22:07:42 -0700
commit34c0a3e334ad884c9d85ef9683a1adafc8beb350 (patch)
tree03ee84d55c36405eac2c3907bd227276cd5a62c1
parent07f5975c5916b843fd5a1e6d227000bbb09201ca (diff)
downloadportage-34c0a3e334ad884c9d85ef9683a1adafc8beb350.tar.gz
portage-34c0a3e334ad884c9d85ef9683a1adafc8beb350.tar.bz2
portage-34c0a3e334ad884c9d85ef9683a1adafc8beb350.zip
Bug #305035 - Fix portdbapi.getfetchsizes() to account for
PORTAGE_RO_DISTDIRS.
-rw-r--r--pym/portage/dbapi/porttree.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 238db8319..07a7b0c62 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -785,10 +785,15 @@ class portdbapi(dbapi):
return {}
filesdict={}
myfiles = self.getFetchMap(mypkg, useflags=useflags)
+ ro_distdirs = [x for x in \
+ shlex_split(self.settings.get("PORTAGE_RO_DISTDIRS", "")) \
+ if os.path.isdir(x)]
#XXX: maybe this should be improved: take partial downloads
# into account? check checksums?
for myfile in myfiles:
- if myfile not in checksums:
+ try:
+ fetch_size = int(checksums[myfile]["size"])
+ except (KeyError, ValueError):
if debug:
writemsg(_("[bad digest]: missing %(file)s for %(pkg)s\n") % {"file":myfile, "pkg":mypkg})
continue
@@ -800,9 +805,18 @@ class portdbapi(dbapi):
pass
if mystat is None:
existing_size = 0
+ for x in ro_distdirs:
+ try:
+ mystat = os.stat(os.path.join(x, myfile))
+ except OSError:
+ pass
+ else:
+ if mystat.st_size == fetch_size:
+ existing_size = fetch_size
+ break
else:
existing_size = mystat.st_size
- remaining_size = int(checksums[myfile]["size"]) - existing_size
+ remaining_size = fetch_size - existing_size
if remaining_size > 0:
# Assume the download is resumable.
filesdict[myfile] = remaining_size