From: Zac Medico Date: Thu, 27 Jul 2006 06:20:11 +0000 (-0000) Subject: Move the initial check of previously fetched files out of the locations loop so that... X-Git-Tag: v2.1.1~138 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b52d704e8894a72d7caefea40bbd3677ea0bd3e0;p=portage.git Move the initial check of previously fetched files out of the locations loop so that that the same code path can be used (patch to follow) when fetch is restricted and there are no custom local mirrors. See bug #37455. svn path=/main/trunk/; revision=4027 --- diff --git a/pym/portage.py b/pym/portage.py index c46aea9f9..d282d75d3 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1890,16 +1890,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: filedict[myfile].append(myuri) - missingSourceHost = False - for myfile in filedict.keys(): # Gives a list, not just the first one - if not filedict[myfile]: - writemsg("Warning: No mirrors available for file '%s'\n" % (myfile), - noiselevel=-1) - missingSourceHost = True - if missingSourceHost: - return 0 - del missingSourceHost - can_fetch=True if not listonly: @@ -1942,6 +1932,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", return 0 del distlocks_subdir for myfile in filedict.keys(): + myfile_path = os.path.join(mysettings["DISTDIR"], myfile) fetched=0 file_lock = None if listonly: @@ -1953,6 +1944,46 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: file_lock = portage_locks.lockfile(mysettings["DISTDIR"]+"/"+myfile,wantnewlockfile=1) try: + if not listonly: + try: + mystat = os.stat(myfile_path) + except OSError, e: + if e.errno != errno.ENOENT: + raise + del e + else: + if myfile not in mydigests: + # We don't have a digest, but the file exists. We must + # assume that it is fully downloaded. + continue + else: + if mystat.st_size < mydigests[myfile]["size"]: + fetched = 1 # Try to resume this download. + else: + verified_ok, reason = portage_checksum.verify_all( + myfile_path, mydigests[myfile]) + if not verified_ok: + writemsg("!!! Previously fetched" + \ + " file: '%s'\n" % myfile, noiselevel=-1) + writemsg("!!! Reason: %s\n" % reason[0], + noiselevel=-1) + writemsg(("!!! Got: %s\n" + \ + "!!! Expected: %s\n") % \ + (reason[1], reason[2]), noiselevel=-1) + if can_fetch: + writemsg("Refetching...\n\n", + noiselevel=-1) + os.unlink(myfile_path) + else: + eout = output.EOutput() + eout.quiet = \ + mysettings.get("PORTAGE_QUIET", None) == "1" + for digest_name in mydigests[myfile]: + eout.ebegin("Previously fetched:" + \ + " %s %s ;-)" % (myfile, digest_name)) + eout.eend(0) + continue # fetch any remaining files + for loc in filedict[myfile]: if listonly: writemsg(loc+" ") @@ -1971,48 +2002,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", fetchcommand=string.replace(fetchcommand,"${DISTDIR}",mysettings["DISTDIR"]) resumecommand=string.replace(resumecommand,"${DISTDIR}",mysettings["DISTDIR"]) - try: - mystat=os.stat(mysettings["DISTDIR"]+"/"+myfile) - if mydigests.has_key(myfile): - #if we have the digest file, we know the final size and can resume the download. - if mystat[stat.ST_SIZE]