summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Bompard <aurelien@bompard.org>2012-11-13 17:39:40 +0100
committerAurélien Bompard <aurelien@bompard.org>2012-11-13 17:39:40 +0100
commit1d9c0213044063b3468082c58af3909d9e99b9d4 (patch)
tree1d6195cd0ee121d4c4bddcfcded44ea2f7f3779e
parent8422e0146269f7dc23d6e18de3590672b3a79494 (diff)
downloadkittystore-1d9c0213044063b3468082c58af3909d9e99b9d4.tar.gz
kittystore-1d9c0213044063b3468082c58af3909d9e99b9d4.tar.xz
kittystore-1d9c0213044063b3468082c58af3909d9e99b9d4.zip
Protect attachment import from duplicate emails
-rw-r--r--kittystore/storm/store.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/kittystore/storm/store.py b/kittystore/storm/store.py
index 4e91346..5d1f8ed 100644
--- a/kittystore/storm/store.py
+++ b/kittystore/storm/store.py
@@ -439,6 +439,13 @@ class StormStore(object):
def add_attachment(self, mlist, msg_id, counter, name, content_type,
encoding, content):
+ existing = self.db.find(Attachment.message_id, And(
+ Attachment.list_name == unicode(mlist),
+ Attachment.message_id == unicode(msg_id),
+ Attachment.counter == counter,
+ )).count()
+ if existing:
+ return
attachment = Attachment()
attachment.list_name = unicode(mlist)
attachment.message_id = unicode(msg_id)