From e37441cd19ae9f216c993650b0d8fded6c2f9a14 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 11 Apr 2011 18:09:07 +0200 Subject: [PATCH] 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 Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/Maildir.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index 083325a..02e64d2 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -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: