]> err.no Git - dak/commitdiff
Add filename de-duplication to contents scanning.
authorTorsten Werner <twerner@debian.org>
Tue, 15 Mar 2011 17:58:39 +0000 (18:58 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 15 Mar 2011 17:58:39 +0000 (18:58 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/contents.py

index bbbacd4a3f73172e4c021e8beda380d2351ac850..27ffdda6cf71879c75abd34b01ee98d3b2fe796c 100755 (executable)
@@ -257,18 +257,12 @@ class ContentsScanner(object):
         '''
         session = DBConn().session()
         binary = session.query(DBBinary).get(self.binary_id)
-        empty_package = True
-        for filename in binary.scan_contents():
+        fileset = set(binary.scan_contents())
+        if len(fileset) == 0:
+            fileset.add('EMPTY_PACKAGE')
+        for filename in fileset:
             binary.contents.append(BinContents(file = filename))
-            empty_package = False
-        if empty_package:
-            binary.contents.append(BinContents(file = 'EMPTY_PACKAGE'))
-        try:
-            session.commit()
-        except IntegrityError:
-            session.rollback()
-            binary.contents.append(BinContents(file = 'DUPLICATE_FILENAMES'))
-            session.commit()
+        session.commit()
         session.close()
 
     @classmethod