X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Farchive.py;h=ca58da87a2858917fda4387173f54fde3796d396;hb=1274df1d98f7004042768c9e2650f5ae9dd79e41;hp=26acaf60effd258a7f810f8ed12356fd7e71ea1f;hpb=6ced52f2a51821cdcb79a11ccd8116a39464f4d0;p=dak.git diff --git a/daklib/archive.py b/daklib/archive.py index 26acaf60..ca58da87 100644 --- a/daklib/archive.py +++ b/daklib/archive.py @@ -33,6 +33,7 @@ import os import shutil import subprocess from sqlalchemy.orm.exc import NoResultFound +import sqlalchemy.exc import tempfile import traceback @@ -85,7 +86,7 @@ class ArchiveTransaction(object): Will not give an error when the file is already present. @rtype: L{daklib.dbconn.PoolFile} - @return: batabase object for the new file + @return: database object for the new file """ session = self.session @@ -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