diff options
| author | Aurélien Bompard <aurelien@bompard.org> | 2012-11-13 17:39:40 +0100 |
|---|---|---|
| committer | Aurélien Bompard <aurelien@bompard.org> | 2012-11-13 17:39:40 +0100 |
| commit | 1d9c0213044063b3468082c58af3909d9e99b9d4 (patch) | |
| tree | 1d6195cd0ee121d4c4bddcfcded44ea2f7f3779e | |
| parent | 8422e0146269f7dc23d6e18de3590672b3a79494 (diff) | |
| download | kittystore-1d9c0213044063b3468082c58af3909d9e99b9d4.tar.gz kittystore-1d9c0213044063b3468082c58af3909d9e99b9d4.tar.xz kittystore-1d9c0213044063b3468082c58af3909d9e99b9d4.zip | |
Protect attachment import from duplicate emails
| -rw-r--r-- | kittystore/storm/store.py | 7 |
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) |
