[yum-git] Branch 'yum-3_2_X' - yum/repoMDObject.py yum/yumRepo.py

James Antill james at linux.duke.edu
Tue Jul 15 21:19:11 UTC 2008


 yum/repoMDObject.py |   27 ++++++++++++++++++---------
 yum/yumRepo.py      |   20 +++++++-------------
 2 files changed, 25 insertions(+), 22 deletions(-)

New commits:
commit 59d3d67fdcbab29edec9742e13e18b6abe837815
Author: James Antill <james at and.org>
Date:   Tue Jul 15 17:15:39 2008 -0400

     Add RepoMD.timestamp attribute, for mirrormanager etc.
     Defined as the biggest/newest timestamp within a data section.
    
      Use this as the canonical timestamp in the repomd checking, and
    tweak the error message.

diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index e0ddb88..d1d8cfb 100644
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -69,6 +69,7 @@ class RepoMD:
     def __init__(self, repoid, srcfile):
         """takes a repoid and a filename for the repomd.xml"""
         
+        self.timestamp = 0
         self.repoid = repoid
         self.repoData = {}
         
@@ -88,6 +89,12 @@ class RepoMD:
                 if elem_name == "data":
                     thisdata = RepoData(elem=elem)
                     self.repoData[thisdata.type] = thisdata
+                    try:
+                        nts = int(thisdata.timestamp)
+                        if nts > self.timestamp: # max() not in old python
+                            self.timestamp = nts
+                    except:
+                        pass
         except SyntaxError, e:
             raise RepoMDError, "Damaged repomd.xml file"
             
@@ -103,20 +110,22 @@ class RepoMD:
             
     def dump(self):
         """dump fun output"""
-        
-        for ft in self.fileTypes():
+
+        print "file timestamp: %s" % self.timestamp
+        for ft in sorted(self.fileTypes()):
             thisdata = self.repoData[ft]
-            print 'datatype: %s' % thisdata.type
-            print 'location: %s %s' % thisdata.location
-            print 'timestamp: %s' % thisdata.timestamp
-            print 'checksum: %s -%s' % thisdata.checksum
-            print 'open checksum: %s - %s' %  thisdata.openchecksum
-            print 'dbversion: %s' % thisdata.dbversion
+            print '  datatype: %s' % thisdata.type
+            print '    location     : %s %s' % thisdata.location
+            print '    timestamp    : %s' % thisdata.timestamp
+            print '    checksum     : %s - %s' % thisdata.checksum
+            print '    open checksum: %s - %s' %  thisdata.openchecksum
+            print '    dbversion    : %s' % thisdata.dbversion
+            print ''
 
 def main():
 
     try:
-        print sys.argv[1]
+        print "file          : %s" % sys.argv[1]
         p = RepoMD('repoid', sys.argv[1])
         p.dump()
         
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 4e281d5..b032b57 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -876,20 +876,14 @@ class YumRepository(Repository, config.RepoConf):
         if 'old_repo_XML' not in self._oldRepoMDData:
             return True
         old_repo_XML = self._oldRepoMDData['old_repo_XML']
-        
-        mdtypes = self.retrieved.keys()
 
-        for mdtype in mdtypes:
-            (nmdtype, newdata) = self._get_mdtype_data(mdtype)
-            (omdtype, olddata) = self._get_mdtype_data(mdtype,
-                                                       repoXML=old_repo_XML)
-            if olddata is None or newdata is None:
-                continue
-            if omdtype == nmdtype and olddata.checksum == newdata.checksum:
-                continue
-            if olddata.timestamp > newdata.timestamp:
-                logger.warning("Not using downloaded repomd.xml because it is older than what we have")
-                return False
+        if old_repo_XML.timestamp > self.repoXML.timestamp:
+            logger.warning("Not using downloaded repomd.xml because it is "
+                           "older than what we have:\n"
+                           "  Current   : %s\n  Downloaded: %s" %
+                           (time.ctime(old_repo_XML.timestamp),
+                            time.ctime(self.repoXML.timestamp)))
+            return False
         return True
 
     def _commonLoadRepoXML(self, text, mdtypes=None):



More information about the Yum-cvs-commits mailing list