Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMAP: Crash can cause Message to be duplicated and processed multiple times. #212

Open
ses4j opened this issue Sep 3, 2019 · 2 comments

Comments

@ses4j
Copy link

ses4j commented Sep 3, 2019

The IMAP transport protocol mailbox fetch works like this:

  1. Get all message IDs (even ones marked \Deleted.)
  2. For each message ID:
    a. fetch the email
    b. call the receive signal
    c. mark it \Deleted
  3. expunge all \Deleted.

We are experiencing the same message being downloaded multiple times, in situations where our polling mechanism crashes in the middle of looping (in our case, due to many messages taking too long and Celery sigkilling the process).

This seems unnecessary. I am no IMAP expert, but from reviewing the IMAP RFC, it seems we could either move the expunge into the loop so it happens after each \Deleted mark, or else change the _get_all_message_ids from:

response, message_ids = self.server.uid('search', None, 'ALL')

to

response, message_ids = self.server.uid('search', None, 'UNDELETED')

Or both... thoughts?

@acmisiti
Copy link

Any update on this? I have also experienced the same issue.

@Rokfordchez
Copy link
Contributor

Every <email.message.Message object> have ['message-id'] header. And it store in model Message.
I think setting to avoid duplicate can be added. For example add this validation to django_mailbox/models/process_incoming_message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants