From 70c9d2d5230660a13698f4d10327c82416c164cf Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Tue, 21 Jul 2009 09:20:14 +0000 Subject: [PATCH] Fixes issue #71: E-mail parsing can cause issues with emails being picked up multiple times. patch provided by hudora.de; thank you! --- management/commands/get_email.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/management/commands/get_email.py b/management/commands/get_email.py index 2755979b..09ae38b4 100644 --- a/management/commands/get_email.py +++ b/management/commands/get_email.py @@ -95,13 +95,17 @@ def process_queue(q): server.login(q.email_box_user, q.email_box_pass) server.select(q.email_box_imap_folder) - status, data = server.search(None, 'ALL') - for num in data[0].split(): - status, data = server.fetch(num, '(RFC822)') - ticket = ticket_from_message(message=data[0][1], queue=q) - if ticket: - server.store(num, '+FLAGS', '\\Deleted') - + while True: + status, data = server.search(None, 'NOT', 'DELETED') + msgnums = data[0].split() + if not msgnums: + break + for num in msgnums: + status, data = server.fetch(num, '(RFC822)') + ticket = ticket_from_message(message=data[0][1], queue=q) + if ticket: + server.store(num, '+FLAGS', '\\Deleted') + server.expunge() server.close() server.logout()