From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 676B31381F3 for ; Thu, 22 Aug 2013 09:01:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ABC28E0B97; Thu, 22 Aug 2013 09:01:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CA1DFE0B22 for ; Thu, 22 Aug 2013 09:01:41 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AC61133ECB7 for ; Thu, 22 Aug 2013 09:01:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 6186AE5463 for ; Thu, 22 Aug 2013 09:01:39 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1377161578.95b98aaa2a04218edef90fb5da223773f92f35b6.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/db/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/db/distmap.py X-VCS-Directories: roverlay/db/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 95b98aaa2a04218edef90fb5da223773f92f35b6 X-VCS-Branch: master Date: Thu, 22 Aug 2013 09:01:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 667a12d1-dd23-4f5f-b1e8-cd6efd874cb4 X-Archives-Hash: 0f926ea61274a4a5c3dc27d52f594cbc commit: 95b98aaa2a04218edef90fb5da223773f92f35b6 Author: André Erdmann mailerd de> AuthorDate: Thu Aug 22 08:52:58 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Thu Aug 22 08:52:58 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=95b98aaa roverlay/db/distmap: accept precalculated digests This allows to calculate digests in a hashpool. --- roverlay/db/distmap.py | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/roverlay/db/distmap.py b/roverlay/db/distmap.py index 34e5dcb..ca3d236 100644 --- a/roverlay/db/distmap.py +++ b/roverlay/db/distmap.py @@ -233,6 +233,10 @@ class _DistMapBase ( object ): return True # --- end of compare_digest (...) --- + def get_hash_type ( self ): + return DistMapInfo.DIGEST_TYPE + # --- end of get_hash_types (...) --- + def get_file_digest ( self, f ): """Returns a file checksum for the given file. @@ -242,6 +246,20 @@ class _DistMapBase ( object ): return roverlay.digest.dodigest_file ( f, DistMapInfo.DIGEST_TYPE ) # --- end of get_file_digest (...) --- + def check_digest_integrity ( self, distfile, digest ): + info = self._distmap.get ( distfile, None ) + + if info is None: + # file not found + return 1 + elif info.digest == digest: + # file OK + return 0 + else: + # bad checksum + return 2 + # --- end of check_digest_integrity (...) --- + def check_integrity ( self, distfile, distfilepath ): """Verifies a distfile by comparing its filepath with the distmap entry. Returns 1 if the file is not in the distmap, 2 if the file's checksum @@ -251,17 +269,12 @@ class _DistMapBase ( object ): * distfile -- distfile path relative to the distroot * distfilepath -- absolute path to the distfile """ - info = self._distmap.get ( distfile, None ) - - if info is None: - # file not found + if self._distmap.get ( distfile, None ) is None: return 1 - elif info.digest == self.get_file_digest ( distfilepath ): - # file OK - return 0 else: - # bad checksum - return 2 + return self.check_digest_integrity ( + distfile, self.get_file_digest ( distfilepath ) + ) # --- end of check_integrity (...) --- def remove ( self, key ): @@ -364,7 +377,7 @@ class _DistMapBase ( object ): ) # --- end of add_entry_for (...) --- - def add_dummy_entry ( self, distfile, distfilepath ): + def add_dummy_entry ( self, distfile, distfilepath=None, hashdict=None ): """Adds a dummy entry. Such an entry contains a checksum and a distfile, but no information about its origin (repo name/file). @@ -372,12 +385,15 @@ class _DistMapBase ( object ): arguments: * distfile -- distfile path relative to the distroot * distfilepath -- absolute path to the distfile + * hashdict -- dict with already calculated hashes """ + if hashdict and DistMapInfo.DIGEST_TYPE in hashdict: + digest = hashdict [DistMapInfo.DIGEST_TYPE] + else: + digest = self.get_file_digest ( distfilepath ) + return self.add_entry ( - distfile, - DistMapInfo ( - distfile, None, None, self.get_file_digest ( distfilepath ), - ) + distfile, DistMapInfo ( distfile, None, None, digest ) ) # --- end of add_dummy_entry (...) ---