[yum-commits] yum/repoMDObject.py

zpavlas at osuosl.org zpavlas at osuosl.org
Wed Oct 24 09:19:30 UTC 2012


 yum/repoMDObject.py |    9 +++++++++
 1 file changed, 9 insertions(+)

New commits:
commit f30863196599291c0fa9f0bc904d3cac970efe0b
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date:   Thu Oct 18 10:22:16 2012 +0200

    multiple/alternative repodata: use "best" instead of "last"

diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index eb84123..97256c6 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -15,6 +15,7 @@
 # Copyright 2006 Duke University
 
 from yum.misc import cElementTree_iterparse as iterparse 
+from yum.misc import _available_compression, stat_f
 from Errors import RepoMDError
 
 import sys
@@ -133,6 +134,7 @@ class RepoMD:
         else:
             # srcfile is a file object
             infile = srcfile
+            srcfile = None
 
         # We trust any of these to mean the repomd.xml is valid.
         infile = AutoFileChecksums(infile, ['sha256', 'sha512'],
@@ -145,6 +147,13 @@ class RepoMD:
                 
                 if elem_name == "data":
                     thisdata = RepoData(elem=elem)
+                    old = self.repoData.get(thisdata.type)
+                    if (old and old.size and old.size < thisdata.size
+                        and old.location[1].rsplit('.', 1)[1] in _available_compression
+                        and srcfile and stat_f(srcfile.rsplit('/', 1)[0] +'/'+
+                                               thisdata.location[1].rsplit('/', 1)[1]) is None):
+                        # previous is smaller, can unzip it, and next is not cached
+                        thisdata = old
                     self.repoData[thisdata.type] = thisdata
                     try:
                         nts = int(thisdata.timestamp)


More information about the Yum-commits mailing list