folder/Maildir: Make use of helper functions

quickchanged() was iterating a lot, make use of some of the helper
functions that had been introduced recently and document the function a
bit better. No functional change.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-04-11 18:09:07 +02:00 committed by Nicolas Sebrecht
parent d762175af4
commit e37441cd19

View File

@ -162,16 +162,17 @@ class MaildirFolder(BaseFolder):
return retval
def quickchanged(self, statusfolder):
"""Returns True if the Maildir has changed"""
self.cachemessagelist()
savedmessages = statusfolder.getmessagelist()
if len(self.messagelist) != len(savedmessages):
# Folder has different uids than statusfolder => TRUE
if sorted(self.getmessageuidlist()) != \
sorted(statusfolder.getmessageuidlist()):
return True
for uid in self.messagelist.keys():
if uid not in savedmessages:
# Also check for flag changes, it's quick on a Maildir
for (uid, message) in self.getmessagelist().iteritems():
if message['flags'] != statusfolder.getmessageflags(uid):
return True
if self.messagelist[uid]['flags'] != savedmessages[uid]['flags']:
return True
return False
return False #Nope, nothing changed
def cachemessagelist(self):
if self.messagelist is None: