[yum-git] yum/__init__.py

Seth Vidal skvidal at linux.duke.edu
Fri Mar 28 06:55:43 UTC 2008


 yum/__init__.py |   33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

New commits:
commit c82f0ddea8d2c113de20d9716b6fe68d5d732251
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Fri Mar 28 02:53:57 2008 -0400

    make our verifyPkg() function handle corrupted files more correctly
    closes rh bug: https://bugzilla.redhat.com/show_bug.cgi?id=439275

diff --git a/yum/__init__.py b/yum/__init__.py
index 3a9998b..48a7da7 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -965,22 +965,32 @@ class YumBase(depsolve.Depsolve):
            raiseError  = defaults to 0 - if 1 then will raise
            a URLGrabError if the file does not check out.
            otherwise it returns false for a failure, true for success"""
+        failed = False
 
         if type(fo) is types.InstanceType:
             fo = fo.filename
             
         if not po.verifyLocalPkg():
+            failed = True
+        else:
+            ylp = YumLocalPackage(self.rpmdb.readOnlyTS(), fo)
+            if ylp.pkgtup != po.pkgtup:
+                failed = True
+
+
+        if failed:            
+            # if the file is wrong AND it is >= what we expected then it
+            # can't be redeemed. If we can, kill it and start over fresh
+            cursize = os.stat(fo)[6]
+            totsize = long(po.size)
+            if cursize >= totsize and not po.repo.cache:
+                os.unlink(fo)
+                                                                                             
             if raiseError:
                 raise URLGrabError(-1, _('Package does not match intended download'))
             else:
                 return False
 
-        ylp = YumLocalPackage(self.rpmdb.readOnlyTS(), fo)
-        if ylp.pkgtup != po.pkgtup:
-            if raiseError:
-                raise URLGrabError(-1, _('Package does not match intended download'))
-            else:
-                return False
         
         return True
         
@@ -1032,16 +1042,17 @@ class YumBase(depsolve.Depsolve):
                     
             local = po.localPkg()
             if os.path.exists(local):
-                cursize = os.stat(local)[6]
-                totsize = long(po.size)
                 if not po.verifyLocalPkg():
                     if po.repo.cache:
                         repo_cached = True
                         adderror(po, _('package fails checksum but caching is '
                             'enabled for %s') % po.repo.id)
-                        
-                    if cursize >= totsize: # otherwise keep it around for regetting
-                        os.unlink(local)
+                    else:
+                        cursize = os.stat(local)[6]
+                        totsize = long(po.size)
+                        if cursize >= totsize:
+                            os.unlink(local)
+
                 else:
                     self.verbose_logger.debug(_("using local copy of %s") %(po,))
                     continue



More information about the Yum-cvs-commits mailing list