public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/db/
Date: Thu, 22 Aug 2013 09:01:39 +0000 (UTC)	[thread overview]
Message-ID: <1377161578.95b98aaa2a04218edef90fb5da223773f92f35b6.dywi@gentoo> (raw)

commit:     95b98aaa2a04218edef90fb5da223773f92f35b6
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Aug 22 08:52:58 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> 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 (...) ---
 


             reply	other threads:[~2013-08-22  9:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-22  9:01 André Erdmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-07-07  4:19 [gentoo-commits] proj/R_overlay:master commit in: roverlay/db/ Benda XU
2014-07-16 15:14 André Erdmann
2013-09-05 14:43 André Erdmann
2013-09-05 14:43 André Erdmann
2013-09-05 14:43 André Erdmann
2013-09-05 10:24 André Erdmann
2013-09-05  9:25 André Erdmann
2013-09-05  9:25 André Erdmann
2013-09-05  9:25 André Erdmann
2013-09-03 15:37 André Erdmann
2013-09-03 13:15 André Erdmann
2013-09-03 12:21 André Erdmann
2013-09-03 12:21 André Erdmann
2013-09-02  8:44 André Erdmann
2013-08-30 15:25 André Erdmann
2013-08-30 15:23 André Erdmann
2013-08-30 14:49 André Erdmann
2013-08-30 14:49 André Erdmann
2013-08-16 14:26 André Erdmann
2013-08-16 12:42 André Erdmann
2013-08-15  9:18 André Erdmann
2013-08-14 14:56 André Erdmann
2013-08-14 14:56 André Erdmann
2013-08-13  8:56 André Erdmann
2013-07-30 18:40 André Erdmann
2013-07-10 15:10 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-10 16:16 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-06-22 15:14 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-22 15:24 ` [gentoo-commits] proj/R_overlay:master " André Erdmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377161578.95b98aaa2a04218edef90fb5da223773f92f35b6.dywi@gentoo \
    --to=dywi@mailerd.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox