From adfb7a63d7ba05152d630fb1a505b95dcde38038 Mon Sep 17 00:00:00 2001 From: Peter Poeml Date: Sun, 18 Jun 2006 11:36:57 +0000 Subject: don't delete more than a certain number of messages at a time. The max command len is limited. Fixes bug 942403 (Archiving large IMAP folders fails) --- archivemail.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'archivemail.py') diff --git a/archivemail.py b/archivemail.py index cee8a9f..3d42b86 100755 --- a/archivemail.py +++ b/archivemail.py @@ -1279,9 +1279,14 @@ def _archive_imap(mailbox_name, final_archive_name): if archive: archive.close() archive.finalise() - vprint("Deleting messages") - imap_srv.store(string.join(message_list, ','), - '+FLAGS.SILENT', '\\Deleted') + # do not delete more than a certain number of messages at a time, because the + # command length is limited. This avoids that servers terminate the connection with + # EOF or TCP RST. + vprint("Deleting %s messages" % len(message_list)) + max_delete = 100 + for i in range(0, len(message_list), max_delete): + imap_srv.store(string.join(message_list[i:i+max_delete], ','), + '+FLAGS.SILENT', '\\Deleted') imap_srv.close() imap_srv.logout() -- cgit v1.2.3