From 66fd3fabe7b16abb0fa61b680067921398ad1f7e Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 11 Jan 2011 15:59:23 +0100 Subject: tracking: Attempt to detect and remove conflicting consignments. --- modules/tracking.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules') diff --git a/modules/tracking.py b/modules/tracking.py index 81c4fd1..0d34b17 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -293,6 +293,15 @@ class Module: consignment = session.query(Consignment).filter(Consignment.code == code).one() self.update_consignment(session, consignment, announce) session.commit() + except IntegrityError as e: + # assume several packets within the same consignment was added as a consignment + target = consignment.channel or consignment.nick + target = target.encode('utf-8') + session.rollback() + session.delete(consignment) + session.commit() + if announce: + self.irc.msg(target, '%s: \002%s\002 conflicts with another consignment - tracking stopped' % (target, code)) finally: session.close() -- cgit v1.2.3