From 41d90f8a760d49812410f0dc3587a2b134c2b0c1 Mon Sep 17 00:00:00 2001 From: Patrick Ulbrich Date: Wed, 18 Dec 2013 13:53:02 +0100 Subject: [PATCH] discard mails with identical ids (both, imap and pop3) added comments --- Mailnag/daemon/mails.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Mailnag/daemon/mails.py b/Mailnag/daemon/mails.py index 8bbbd56..1f6567d 100644 --- a/Mailnag/daemon/mails.py +++ b/Mailnag/daemon/mails.py @@ -103,7 +103,11 @@ class MailCollector: id = hashlib.md5((acc.server + folder + acc.user + sender[1] + subject + hash_datetime) .encode('utf-8')).hexdigest() - # prevent duplicates caused by Gmail labels + + # Discard mails with identical IDs (caused + # by mails received in the same folder with + # identical sender and subject but *no datetime*). + # Also filter duplicates caused by Gmail labels. if id not in mail_ids: mail_list.append(Mail(datetime, subject, \ sender, id, acc.get_id())) @@ -141,8 +145,12 @@ class MailCollector: id = hashlib.md5((acc.server + acc.user + sender[1] + subject + hash_datetime) .encode('utf-8')).hexdigest() - mail_list.append(Mail(datetime, subject, sender, \ - id, acc.get_id())) + # Discard mails with identical IDs (caused + # by mails with identical sender and subject but *no datetime*). + if id not in mail_ids: + mail_list.append(Mail(datetime, subject, sender, \ + id, acc.get_id())) + mail_ids[id] = None # disconnect from Email-Server srv.quit()