]> git.decadent.org.uk Git - dak.git/commitdiff
Do not try to add same hashfile multiple times
authorAnsgar Burchardt <ansgar@debian.org>
Wed, 18 May 2016 21:53:03 +0000 (23:53 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Wed, 18 May 2016 21:53:03 +0000 (23:53 +0200)
Doing so would violate the database constraints.

dak/generate_releases.py

index 45f172d20df287f8d776d44f2107c5bffce6b4c3..cc6327f0c9d2030fcdd011a9b00e16dfb29931c9 100755 (executable)
@@ -206,8 +206,8 @@ class ReleaseWriter(object):
             query = "SELECT path FROM hashfile WHERE suite_id = :id"
             q = session.execute(query, {'id': self.suite.suite_id})
             known_hashfiles = set(row[0] for row in q)
-            updated = []
-            new = []
+            updated = set()
+            new = set()
 
             # Update the hashfile table with new or updated files
             for filename in fileinfo:
@@ -219,15 +219,15 @@ class ReleaseWriter(object):
                     field = h.release_field
                     hashfile = os.path.join(byhashdir, field, fileinfo[filename][field])
                     if hashfile in known_hashfiles:
-                        updated.append(hashfile)
+                        updated.add(hashfile)
                     else:
-                        new.append(hashfile)
+                        new.add(hashfile)
 
             if updated:
                 session.execute("""
                     UPDATE hashfile SET unreferenced = NULL
                     WHERE path = ANY(:p) AND suite_id = :id""",
-                    {'p': updated, 'id': self.suite.suite_id})
+                    {'p': list(updated), 'id': self.suite.suite_id})
             if new:
                 session.execute("""
                     INSERT INTO hashfile (path, suite_id)