[PATCH 1/2] folder/Maildir: Make use of helper functions

Sebastian Spaeth Sebastian at SSpaeth.de
Mon Apr 11 17:09:07 BST 2011


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 at SSpaeth.de>
---
Tested this one, no functional changes, just some cleanup. We can apply
or postpone after the release.


 offlineimap/folder/Maildir.py |   15 ++++++++-------
 1 files 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:
-- 
1.7.1





More information about the OfflineIMAP-project mailing list