Use the max_connection attribute from metalink parser
when building MirrorGroup arguments, so it's available
to the parallel download scheduller.
---
 yum/metalink.py |    2 +-
 yum/yumRepo.py  |   12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/yum/metalink.py b/yum/metalink.py
index aaa4f25..90b0053 100755
--- a/yum/metalink.py
+++ b/yum/metalink.py
@@ -248,7 +248,7 @@ class MetaLinkRepoMD:
             # of mirror baseurls. Joy of reusing other people's stds. :)
             if not url.endswith("/repodata/repomd.xml"):
                 continue
-            yield url[:-len("/repodata/repomd.xml")]
+            yield url[:-len("/repodata/repomd.xml")], mirror.max_connections
 
     def __str__(self):
         ret = str(self.repomd)
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 91b7dde..1181fae 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -287,6 +287,7 @@ class YumRepository(Repository, config.RepoConf):
 
         self._grabfunc = None
         self._grab = None
+        self._max_connections = {}
 
     def __cmp__(self, other):
         """ Sort yum repos. by cost, and then by alphanumeric on their id. """
@@ -491,7 +492,11 @@ class YumRepository(Repository, config.RepoConf):
                                     reget='simple',
                                     **ugopts)
 
-        self._grab = mgclass(self._grabfunc, self.urls,
+        def max_con(url):
+            con = self._max_connections.get(url)
+            if con: url = { 'mirror': misc.to_utf8(url), 'max_connections': 
con }
+            return url
+        self._grab = mgclass(self._grabfunc, map(max_con, self.urls),
                              failure_callback=self.mirror_failure_obj)
 
     def _default_grabopts(self, cache=True):
@@ -675,7 +680,7 @@ class YumRepository(Repository, config.RepoConf):
     def _replace_and_check_url(self, url_list):
         goodurls = []
         skipped = None
-        for url in url_list:
+        for url, con in url_list:
             # obvious bogons get ignored b/c, we could get more interesting 
checks but <shrug>
             if url in ['', None]:
                 continue
@@ -692,6 +697,7 @@ class YumRepository(Repository, config.RepoConf):
                 skipped = url
                 continue
             else:
+                self._max_connections[url] = con
                 goodurls.append(url)
 
         if skipped is not None:
@@ -1698,7 +1704,7 @@ Insufficient space in download directory %s
                     continue
                 mirror = line.rstrip() # no more trailing \n's
                 mirror = mirror.replace('$ARCH', '$BASEARCH')
-                returnlist.append(mirror)
+                returnlist.append((mirror, None))
 
         return (returnlist, content)
 
-- 
1.7.4.4

_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to