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

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