much faster deleting of messages from LocalStatus

After tens of thousands of messages on the IMAP server were deleted it
takes offlineimap extremely long time (several hours of high CPU usage)
to delete them locally. It spends almost all the time modifying
LocalStatus. It processes the messages one by one, rewriting the
folder's status file in LocalStatus after each message.

It is much more efficient to save the status file only once, after
removing all the messages from the messagelist.

Deleting lots of messages now takes seconds instead of hours.

This should solve Debian bug #518093:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518093

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
This commit is contained in:
Michal Schmidt 2010-03-27 16:18:25 +01:00 committed by John Goerzen
parent 30344587d9
commit caa7d8a128

View File

@ -141,7 +141,14 @@ class LocalStatusFolder(BaseFolder):
self.autosave() self.autosave()
def deletemessage(self, uid): def deletemessage(self, uid):
if not uid in self.messagelist: self.deletemessages([uid])
def deletemessages(self, uidlist):
# Weed out ones not in self.messagelist
uidlist = [uid for uid in uidlist if uid in self.messagelist]
if not len(uidlist):
return return
del(self.messagelist[uid])
for uid in uidlist:
del(self.messagelist[uid])
self.autosave() self.autosave()