From: Ansgar Burchardt Date: Wed, 18 May 2016 21:53:03 +0000 (+0200) Subject: Do not try to add same hashfile multiple times X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=6faeb3887dfeb31be66e8b699fd3b366e09a4e91;p=dak.git Do not try to add same hashfile multiple times Doing so would violate the database constraints. --- diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 45f172d2..cc6327f0 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -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)