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

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