[yum-commits] urlgrabber/mirror.py

zpavlas at osuosl.org zpavlas at osuosl.org
Tue Jul 17 08:05:07 UTC 2012


 urlgrabber/mirror.py |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

New commits:
commit 729e68d049f2a58c98177f0e97e08f1c0078eca6
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date:   Thu Jul 12 17:09:55 2012 +0200

    Fix the "file:// && copy_local==0 && async" case.  BZ 837018.
    
    urlgrab() should return url instead of filename if copying
    was skipped.  Reuse the blocking code and enqueue only if
    necessary.
    
    warning: When downloading is skipped, checkfunc is called
    immediately and not deferred to parallel_wait().

diff --git a/urlgrabber/mirror.py b/urlgrabber/mirror.py
index d699b61..0e3512e 100644
--- a/urlgrabber/mirror.py
+++ b/urlgrabber/mirror.py
@@ -94,7 +94,7 @@ import random
 import thread  # needed for locking to make this threadsafe
 
 from grabber import URLGrabError, CallbackObject, DEBUG, _to_utf8
-from grabber import _run_callback, _do_raise, _async_queue
+from grabber import _run_callback, _do_raise
 
 def _(st): 
     return st
@@ -407,19 +407,12 @@ class MirrorGroup:
                 self._failure(gr, obj)
 
     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
-
         kw = dict(kwargs)
         kw['filename'] = filename
+        if kw.get('async'):
+            # enable mirror failovers in async path
+            kw['mirror_group'] = self, set()
+            kw['relative_url'] = url
         func = 'urlgrab'
         try:
             return self._mirror_try(func, url, kw)


More information about the Yum-commits mailing list