Blame SOURCES/BZ-1397829-fix-reget-simple-md-fnames.patch

5e9bef
diff -up yum-3.4.3/yum/yumRepo.py.orig yum-3.4.3/yum/yumRepo.py
5e9bef
--- yum-3.4.3/yum/yumRepo.py.orig	2017-03-10 14:16:36.769105433 +0100
5e9bef
+++ yum-3.4.3/yum/yumRepo.py	2017-03-10 14:16:39.457093071 +0100
5e9bef
@@ -358,6 +358,7 @@ class YumRepository(Repository, config.R
5e9bef
         # holder for stuff we've grabbed
5e9bef
         self.retrieved = { 'primary':0, 'filelists':0, 'other':0, 'group':0,
5e9bef
                            'updateinfo':0, 'prestodelta':0}
5e9bef
+        self._preloaded_repomd = False
5e9bef
 
5e9bef
         # callbacks
5e9bef
         self.callback = None  # for the grabber
5e9bef
@@ -743,7 +744,8 @@ class YumRepository(Repository, config.R
5e9bef
                 
5e9bef
         # if we're using a cachedir that's not the system one, copy over these
5e9bef
         # basic items from the system one
5e9bef
-        self._preload_md_from_system_cache('repomd.xml')
5e9bef
+        if self._preload_md_from_system_cache('repomd.xml'):
5e9bef
+            self._preloaded_repomd = True
5e9bef
         self._preload_md_from_system_cache('cachecookie')
5e9bef
         self._preload_md_from_system_cache('mirrorlist.txt')
5e9bef
         self._preload_md_from_system_cache('metalink.xml')
5e9bef
@@ -1829,6 +1831,12 @@ Insufficient space in download directory
5e9bef
             # got it, move along
5e9bef
             return local
5e9bef
 
5e9bef
+        # Having preloaded the repomd means we should first try preloading this
5e9bef
+        # file as well (forcing it this way is only needed when dealing with
5e9bef
+        # simple filenames).
5e9bef
+        if self._preloaded_repomd:
5e9bef
+            misc.unlink_f(local)
5e9bef
+
5e9bef
         if (os.path.exists(local) or
5e9bef
             self._preload_md_from_system_cache(os.path.basename(local))):
5e9bef
             if self._checkMD(local, mdtype, check_can_fail=True):
5e9bef
@@ -1844,6 +1852,20 @@ Insufficient space in download directory
5e9bef
                 msg = "Caching enabled but no local cache of %s from %s" % (local, self.ui_id)
5e9bef
             raise Errors.RepoError, msg
5e9bef
 
5e9bef
+        # Given the file already exists, is it a partial download of thisdata
5e9bef
+        # that we can try to reget?  With unique filenames, that's always.
5e9bef
+        # With simple filenames, use the old expected checksum to verify
5e9bef
+        # (assuming the existing file or part represents the old data but it
5e9bef
+        # usually does).
5e9bef
+        partial = True
5e9bef
+        orepomd = self._oldRepoMDData.get('old_repo_XML')
5e9bef
+        if orepomd is not None:
5e9bef
+            odata = orepomd.repoData.get(mdtype)
5e9bef
+            if odata is not None:
5e9bef
+                ofname = os.path.basename(odata.location[1])
5e9bef
+                partial = (fname != ofname or
5e9bef
+                           thisdata.checksum == odata.checksum)
5e9bef
+
5e9bef
         try:
5e9bef
             def checkfunc(obj):
5e9bef
                 try:
5e9bef
@@ -1856,7 +1878,7 @@ Insufficient space in download directory
5e9bef
                     raise
5e9bef
                 self.retrieved[mdtype] = 1
5e9bef
             text = "%s/%s" % (self.ui_id, mdtype)
5e9bef
-            if thisdata.size is None:
5e9bef
+            if thisdata.size is None or not partial:
5e9bef
                 reget = None
5e9bef
             else:
5e9bef
                 reget = 'simple'