Prefer thirdpartymirrors over normal mirrors in cases when the file does not
authorZac Medico <zmedico@gentoo.org>
Mon, 20 Oct 2008 19:11:15 +0000 (19:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 20 Oct 2008 19:11:15 +0000 (19:11 -0000)
yet exist on the normal mirrors. Thanks to Maurice van der Pot <griffon26@g.o>
for reporting.

svn path=/main/trunk/; revision=11706

pym/portage/__init__.py

index d13c2f7fb112ec184dccc3dcf2ec5f11732daa45..dfc332f65bc6c2f5be0dc0e855c7831f4a19b76f 100644 (file)
@@ -3494,6 +3494,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
        filedict={}
        primaryuri_indexes={}
        primaryuri_dict = {}
+       thirdpartymirror_uris = {}
        for myfile, myuri in file_uri_tuples:
                if myfile not in filedict:
                        filedict[myfile]=[]
@@ -3517,9 +3518,10 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                if mirrorname in thirdpartymirrors:
                                        shuffle(thirdpartymirrors[mirrorname])
 
-                                       for locmirr in thirdpartymirrors[mirrorname]:
-                                               filedict[myfile].append(
-                                                       locmirr.rstrip("/") + "/" + path)
+                                       uris = [locmirr.rstrip("/") + "/" + path \
+                                               for locmirr in thirdpartymirrors[mirrorname]]
+                                       filedict[myfile].extend(uris)
+                                       thirdpartymirror_uris.setdefault(myfile, []).extend(uris)
 
                                if not filedict[myfile]:
                                        writemsg("No known mirror by the name: %s\n" % (mirrorname))
@@ -3545,6 +3547,11 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                primaryuri_dict[myfile] = primaryuris
                        primaryuris.append(myuri)
 
+       # Prefer thirdpartymirrors over normal mirrors in cases when
+       # the file does not yet exist on the normal mirrors.
+       for myfile, uris in thirdpartymirror_uris.iteritems():
+               primaryuri_dict.setdefault(myfile, []).extend(uris)
+
        can_fetch=True
 
        if listonly: