From: Ansgar Burchardt <ansgar@debian.org>
Date: Sun, 10 Aug 2014 16:22:01 +0000 (+0200)
Subject: Only inject processed uploads into signature_history
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1807bcb3ba6d31dfa058deaa6b7cbd3a3b1b6e8b;p=dak.git

Only inject processed uploads into signature_history

Uploads that were 'skipped' should not be recorded in
signature_history as they will be repeocessed later.
---

diff --git a/dak/process_upload.py b/dak/process_upload.py
index 1518d262..9eb23f00 100755
--- a/dak/process_upload.py
+++ b/dak/process_upload.py
@@ -463,6 +463,13 @@ def process_it(directory, changes, keyrings, session):
     with daklib.archive.ArchiveUpload(directory, changes, keyrings) as upload:
         processed = action(directory, upload)
         if processed and not Options['No-Action']:
+            session = DBConn().session()
+            history = SignatureHistory.from_signed_file(upload.changes)
+            if history.query(session) is None:
+                session.add(history)
+                session.commit()
+            session.close()
+
             unlink_if_exists(os.path.join(directory, changes.filename))
             for fn in changes.files:
                 unlink_if_exists(os.path.join(directory, fn))
diff --git a/daklib/checks.py b/daklib/checks.py
index 3fb883c5..43682737 100644
--- a/daklib/checks.py
+++ b/daklib/checks.py
@@ -112,13 +112,11 @@ class SignatureAndHashesCheck(Check):
     def check_replay(self, upload):
         # Use private session as we want to remember having seen the .changes
         # in all cases.
-        session = DBConn().session()
+        session = upload.session
         history = SignatureHistory.from_signed_file(upload.changes)
         r = history.query(session)
         if r is not None:
             raise Reject('Signature for changes file was already seen at {0}.\nPlease refresh the signature of the changes file if you want to upload it again.'.format(r.seen))
-        session.add(history)
-        session.commit()
         return True
 
     """Check signature of changes and dsc file (if included in upload)