From e893125da2f260c73ac728c5f027113ef9aa2f73 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 5 Jan 2013 07:18:29 -0800 Subject: BinpkgVerifier: use async FileDigester --- pym/portage/dbapi/bintree.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'pym/portage/dbapi') diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 890e8e10b..f6fc11498 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -1356,19 +1356,14 @@ class binarytree(object): f.close() return pkgindex - def digestCheck(self, pkg): - """ - Verify digests for the given package and raise DigestException - if verification fails. - @rtype: bool - @return: True if digests could be located, False otherwise. - """ - cpv = pkg - if not isinstance(cpv, basestring): + def _get_digests(self, pkg): + + try: cpv = pkg.cpv - pkg = None + except AttributeError: + cpv = pkg - pkg_path = self.getname(cpv) + digests = {} metadata = None if self._remotepkgs is None or cpv not in self._remotepkgs: for d in self._load_pkgindex().packages: @@ -1378,9 +1373,8 @@ class binarytree(object): else: metadata = self._remotepkgs[cpv] if metadata is None: - return False + return digests - digests = {} for k in hashfunc_map: v = metadata.get(k) if not v: @@ -1394,9 +1388,27 @@ class binarytree(object): writemsg(_("!!! Malformed SIZE attribute in remote " \ "metadata for '%s'\n") % cpv) + return digests + + def digestCheck(self, pkg): + """ + Verify digests for the given package and raise DigestException + if verification fails. + @rtype: bool + @return: True if digests could be located, False otherwise. + """ + + digests = self._get_digests(pkg) + if not digests: return False + try: + cpv = pkg.cpv + except AttributeError: + cpv = pkg + + pkg_path = self.getname(cpv) hash_filter = _hash_filter( self.settings.get("PORTAGE_CHECKSUM_FILTER", "")) if not hash_filter.transparent: -- cgit v1.2.3-1-g7c22