From: Ansgar Burchardt Date: Sat, 17 Nov 2012 13:25:25 +0000 (+0100) Subject: daklib/archive.py: give a nicer error message for already known .changes X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76bcea909c8a45646123385d82793e8d00ba87b7;p=dak daklib/archive.py: give a nicer error message for already known .changes Bug-Debian: http://bugs.debian.org/693163 --- diff --git a/daklib/archive.py b/daklib/archive.py index 26acaf60..6a424cdf 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 @@ -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