]> err.no Git - dak/commitdiff
daklib/archive.py: give a nicer error message for already known .changes
authorAnsgar Burchardt <ansgar@debian.org>
Sat, 17 Nov 2012 13:25:25 +0000 (14:25 +0100)
committerAnsgar Burchardt <ansgar@debian.org>
Sat, 17 Nov 2012 13:26:04 +0000 (14:26 +0100)
Bug-Debian: http://bugs.debian.org/693163

daklib/archive.py

index 26acaf60effd258a7f810f8ed12356fd7e71ea1f..6a424cdfdc08a91632daff29bc2785d8d7a637bf 100644 (file)
@@ -33,6 +33,7 @@ import os
 import shutil
 import subprocess
 from sqlalchemy.orm.exc import NoResultFound
+import sqlalchemy.exc
 import tempfile
 import traceback
 
@@ -1004,8 +1005,11 @@ class ArchiveUpload(object):
         db_changes.changelog_id = changelog_id
         db_changes.closes = self.changes.closed_bugs
 
-        self.transaction.session.add(db_changes)
-        self.transaction.session.flush()
+        try:
+            self.transaction.session.add(db_changes)
+            self.transaction.session.flush()
+        except sqlalchemy.exc.IntegrityError:
+            raise ArchiveException('{0} is already known.'.format(self.changes.filename))
 
         return db_changes