Use a packages checksum to validate cached download
Using a package size is not good enough, fails to see a changed gpg sig.
This commit is contained in:
parent
01d756a34a
commit
804be3f018
@ -74,6 +74,22 @@ class Gather(yum.YumBase):
|
|||||||
# the logging.
|
# the logging.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def verifyCachePkg(self, po, path): # Stolen from yum
|
||||||
|
"""check the package checksum vs the cache
|
||||||
|
return True if pkg is good, False if not"""
|
||||||
|
|
||||||
|
(csum_type, csum) = po.returnIdSum()
|
||||||
|
|
||||||
|
try:
|
||||||
|
filesum = yum.misc.checksum(csum_type, path)
|
||||||
|
except yum.Errors.MiscError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if filesum != csum:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def getPackageDeps(self, po):
|
def getPackageDeps(self, po):
|
||||||
"""Add the dependencies for a given package to the
|
"""Add the dependencies for a given package to the
|
||||||
transaction info"""
|
transaction info"""
|
||||||
@ -282,8 +298,7 @@ class Gather(yum.YumBase):
|
|||||||
remote = pkg.relativepath
|
remote = pkg.relativepath
|
||||||
local = os.path.basename(remote)
|
local = os.path.basename(remote)
|
||||||
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
||||||
if (os.path.exists(local) and
|
if os.path.exists(local) and self.verifyCachePkg(pkg, local):
|
||||||
os.path.getsize(local) == pkg.packagesize):
|
|
||||||
|
|
||||||
if not self.config.has_option('default', 'quiet'):
|
if not self.config.has_option('default', 'quiet'):
|
||||||
self.logger.info("%s already exists and appears to be complete" % local)
|
self.logger.info("%s already exists and appears to be complete" % local)
|
||||||
@ -349,11 +364,11 @@ class Gather(yum.YumBase):
|
|||||||
remote = pkg.relativepath
|
remote = pkg.relativepath
|
||||||
local = os.path.basename(remote)
|
local = os.path.basename(remote)
|
||||||
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
local = os.path.join(self.config.get('default', 'cachedir'), local)
|
||||||
if os.path.exists(local) and str(os.path.getsize(local)) == pkg.packagesize:
|
if os.path.exists(local) and self.verifyCachePkg(pkg, local):
|
||||||
|
|
||||||
if not self.config.has_option('default', 'quiet'):
|
if not self.config.has_option('default', 'quiet'):
|
||||||
self.logger.info("%s already exists and appears to be complete" % local)
|
self.logger.info("%s already exists and appears to be complete" % local)
|
||||||
if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and str(os.path.getsize(os.path.join(pkgdir, os.path.basename(remote)))) == pkg.packagesize:
|
if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and self.verifyCachePkg(pkg, os.path.join(pkgdir, os.path.basename(remote))) == pkg.packagesize:
|
||||||
if not self.config.has_option('default', 'quiet'):
|
if not self.config.has_option('default', 'quiet'):
|
||||||
self.logger.info("%s already exists in tree and appears to be complete" % local)
|
self.logger.info("%s already exists in tree and appears to be complete" % local)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user