From: Zac Medico Date: Mon, 19 Jul 2010 05:07:42 +0000 (-0700) Subject: Bug #305035 - Fix portdbapi.getfetchsizes() to account for X-Git-Tag: v2.2_rc68~489 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=34c0a3e334ad884c9d85ef9683a1adafc8beb350;p=portage.git Bug #305035 - Fix portdbapi.getfetchsizes() to account for PORTAGE_RO_DISTDIRS. --- 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