[Yum-devel] [PATCH] Fix the "file:// && copy_local=0 && async" case. BZ 837018.

Zdeněk Pavlas zpavlas at redhat.com
Thu Jul 12 15:47:51 UTC 2012


urlgrab() should return url instead of filename if copying
was skipped, but the async path cannot alter the return value,
and we can't detect file:// URLs until we have selected a mirror.

Use 1st mirror temporarily and call the non-mirrored urlgrab()
to handle this special case immediately.  Otherwise, request
is queued and the filename arg is returned.
---
 urlgrabber/mirror.py |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/urlgrabber/mirror.py b/urlgrabber/mirror.py
index d699b61..f2b5288 100644
--- a/urlgrabber/mirror.py
+++ b/urlgrabber/mirror.py
@@ -408,15 +408,15 @@ class MirrorGroup:
 
     def urlgrab(self, url, filename=None, **kwargs):
         if kwargs.get('async'):
-            opts = self.grabber.opts.derive(**kwargs)
-            opts.mirror_group = self, set()
-            opts.relative_url = _to_utf8(url)
-
-            opts.url = 'http://tbd'
-            opts.filename = filename
-            opts.size = int(opts.size or 0)
-            _async_queue.append(opts)
-            return filename
+            return self.grabber.urlgrab(
+                # use 1st mirror to handle the file:// && copy_local==0 case
+                self._join_url(self.mirrors[0]['mirror'], url),
+                filename,
+                # enable mirror failovers in async path
+                mirror_group = (self, set()),
+                relative_url = url,
+                **kwargs
+            )
 
         kw = dict(kwargs)
         kw['filename'] = filename
-- 
1.7.4.4



More information about the Yum-devel mailing list