This is not significantly faster than always downloading the
whole file (repomd.xml is typically about 3kB), we just save
the bandwidth.

With reget on, urlgrabber does not touch the local file
on (most of) failures hence no reverting is needed.

Won't work with older urlgrabber which raises NotImplemented.
Needs to bump Requires: in .spec
---
 yum/yumRepo.py |   20 ++------------------
 1 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 14f6d5f..2d8a1ba 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1090,41 +1090,25 @@ Insufficient space in download directory %s
         checkfunc = (self._checkRepoXML, (), {})
         if grab_can_fail is None:
             grab_can_fail = 'old_repo_XML' in self._oldRepoMDData
-        tfname = ''
         try:
-            # This is named so that "yum clean metadata" picks it up
-            tfname = tempfile.mktemp(prefix='repomd', suffix="tmp.xml",
-                                     dir=os.path.dirname(local))
             result = self._getFile(relative=self.repoMDFile,
-                                   local=tfname,
+                                   local=local,
                                    copy_local=1,
                                    text=text,
-                                   reget=None,
+                                   reget='check_timestamp',
                                    checkfunc=checkfunc,
                                    cache=self.http_caching == 'all',
                                    size=102400) # setting max size as 100K
 
         except URLGrabError, e:
-            misc.unlink_f(tfname)
             if grab_can_fail:
                 return None
             raise Errors.RepoError, 'Error downloading file %s: %s' % (local, 
e)
         except Errors.RepoError:
-            misc.unlink_f(tfname)
             if grab_can_fail:
                 return None
             raise
 
-        # This should always work...
-        try:
-            os.rename(result, local)
-        except:
-            # But in case it doesn't...
-            misc.unlink_f(tfname)
-            if grab_can_fail:
-                return None
-            raise Errors.RepoError, 'Error renaming file %s to %s' % (result,
-                                                                      local)
         return local
 
     def _parseRepoXML(self, local, parse_can_fail=None):
-- 
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