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