[Yum-devel] [PATCH 1/3] Add arg 'hint' to YumAvailablePackage.verifyLocalPkg()

Zdeněk Pavlas zpavlas at redhat.com
Thu Jun 30 17:21:22 UTC 2011


If we already know the local file checksum, verifyLocalPkg()
does not have to calculate it again (unless it's wrong).
---
 yum/packages.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/yum/packages.py b/yum/packages.py
index 5ef9951..d5de234 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -896,7 +896,7 @@ class YumAvailablePackage(PackageObject, RpmBase):
 
         return self.hdrpath
     
-    def verifyLocalPkg(self):
+    def verifyLocalPkg(self, hint = None):
         """check the package checksum vs the localPkg
            return True if pkg is good, False if not"""
 
@@ -918,8 +918,13 @@ class YumAvailablePackage(PackageObject, RpmBase):
         (csum_type, csum) = self.returnIdSum()
         
         try:
-            filesum = misc.checksum(csum_type, self.localPkg(),
-                                    datasize=self.packagesize)
+            if hint and hint == csum:
+                # urlgrabber's checksum matches, use it
+                filesum = hint
+            else:
+                # get rid of false negatives
+                filesum = misc.checksum(csum_type, self.localPkg(),
+                                        datasize=self.packagesize)
         except Errors.MiscError:
             return False
         
-- 
1.7.4.4



More information about the Yum-devel mailing list