diff options
author | Nikolaus Schulz <microschulz@web.de> | 2007-11-02 13:21:18 +0000 |
---|---|---|
committer | Nikolaus Schulz <microschulz@web.de> | 2007-11-02 13:21:18 +0000 |
commit | 0eba452d939e1ba0b740e63bab44d2f01aac4262 (patch) | |
tree | 8834794a882e53f1d2e4c74044bfdcfb5c3dcd8d | |
parent | 130a5ef117806c223d36d6a4ccd3a9de03866df5 (diff) | |
download | archivemail-0eba452d939e1ba0b740e63bab44d2f01aac4262.tar.gz archivemail-0eba452d939e1ba0b740e63bab44d2f01aac4262.tar.bz2 archivemail-0eba452d939e1ba0b740e63bab44d2f01aac4262.zip |
IMAP: first fetch message flags, then the body. Doing it together always
returns the \Seen flag set.
Closes: Debian bug #434807 (well, the outstanding part of it).
-rwxr-xr-x | archivemail.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/archivemail.py b/archivemail.py index 1f14b65..780d03c 100755 --- a/archivemail.py +++ b/archivemail.py @@ -1388,14 +1388,19 @@ def _archive_imap(mailbox_name, final_archive_name): if not options.dry_run: if not options.delete_old_mail: for msn in message_list: - result, response = imap_srv.fetch(msn, '(RFC822 FLAGS)') + # Fetching message flags and body together always finds \Seen + # set. To check \Seen, we must fetch the flags first. + result, response = imap_srv.fetch(msn, '(FLAGS)') + if result != 'OK': unexpected_error("Failed to fetch message " + "flags; server says '%s'" % response[0]) + msg_flags = imaplib.ParseFlags(response[0]) + result, response = imap_srv.fetch(msn, '(RFC822)') if result != 'OK': unexpected_error("Failed to fetch message; " "server says '%s'" % response[0]) if "\r\n" == os.linesep: msg_str = response[0][1] else: msg_str = response[0][1].replace("\r\n", os.linesep) - msg_flags = imaplib.ParseFlags(response[0][0]) msg = rfc822.Message(cStringIO.StringIO(msg_str)) add_status_headers_imap(msg, msg_flags) vprint("processing message '%s'" % msg.get('Message-ID')) |