X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Farchive.py;h=806ba40211b82d31ee6840aa8e8e48e9c6875436;hb=0fd24759c7d4d1c5c0398fb0bc775ca0d77a9310;hp=2c25e1007dfccaa320e8812a70cecc4e805cfe2b;hpb=55d2c7e6e2418518704623246021021e05b90e58;p=dak.git diff --git a/daklib/archive.py b/daklib/archive.py index 2c25e100..806ba402 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 @@ -651,7 +652,13 @@ class ArchiveUpload(object): continue fs.copy(src, dst, mode=0o640) - source = self.changes.source + source = None + try: + source = self.changes.source + except Exception: + # Do not raise an exception here if the .dsc is invalid. + pass + if source is not None: for f in source.files.itervalues(): src = os.path.join(self.original_directory, f.filename) @@ -754,7 +761,7 @@ class ArchiveUpload(object): if self.changes.source is not None: override = self._source_override(suite, self.changes.source) if override is None: - self.warnings.append('source:{0} is NEW.'.format(self.changes.source.control['Source'])) + self.warnings.append('source:{0} is NEW.'.format(self.changes.source.dsc['Source'])) new = True # Check if we reference a file only in a tainted archive @@ -1004,8 +1011,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