diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index bdae5c3..df2e654 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -248,8 +248,17 @@ class BaseFolder(object): raise NotImplementedError + def ismessagelistempty(self): + """Empty everythings we know about messages.""" + + if len(self.messagelist.keys()) < 1: + return True + return False + def dropmessagelistcache(self): - raise NotImplementedException + """Empty everythings we know about messages.""" + + self.messagelist = {} def getmessagelist(self): """Gets the current message list. diff --git a/offlineimap/folder/GmailMaildir.py b/offlineimap/folder/GmailMaildir.py index 5ca0e1f..894792d 100644 --- a/offlineimap/folder/GmailMaildir.py +++ b/offlineimap/folder/GmailMaildir.py @@ -65,7 +65,7 @@ class GmailMaildirFolder(MaildirFolder): def cachemessagelist(self): - if self.messagelist is None: + if self.ismessagelistempty(): self.messagelist = self._scanfolder() # Get mtimes diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index c7e6516..ccc83b0 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -48,7 +48,7 @@ class IMAPFolder(BaseFolder): self.expunge = repository.getexpunge() self.root = None # imapserver.root self.imapserver = imapserver - self.messagelist = None + self.messagelist = {} self.randomgenerator = random.Random() #self.ui is set in BaseFolder self.imap_query = ['BODY.PEEK[]'] @@ -249,7 +249,7 @@ class IMAPFolder(BaseFolder): self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime} def dropmessagelistcache(self): - self.messagelist = None + self.messagelist = {} # Interface from BaseFolder def getmessagelist(self): diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py index c753f63..78f2134 100644 --- a/offlineimap/folder/LocalStatus.py +++ b/offlineimap/folder/LocalStatus.py @@ -155,9 +155,6 @@ class LocalStatusFolder(BaseFolder): self.readstatus(cachefd) cachefd.close() - def dropmessagelistcache(self): - self.messagelist = None - def save(self): """Save changed data to disk. For this backend it is the same as saveall.""" diff --git a/offlineimap/folder/LocalStatusSQLite.py b/offlineimap/folder/LocalStatusSQLite.py index 8a3b9df..a53b48e 100644 --- a/offlineimap/folder/LocalStatusSQLite.py +++ b/offlineimap/folder/LocalStatusSQLite.py @@ -202,7 +202,7 @@ class LocalStatusSQLiteFolder(BaseFolder): self.messagelist[uid]['mtime'] = row[2] def dropmessagelistcache(self): - self.messagelist = None + self.messagelist = {} # Interface from LocalStatusFolder def save(self): diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index b35bfc2..4bbfe7e 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -63,7 +63,7 @@ class MaildirFolder(BaseFolder): super(MaildirFolder, self).__init__(name, repository) self.dofsync = self.config.getdefaultboolean("general", "fsync", True) self.root = root - self.messagelist = None + self.messagelist = {} # check if we should use a different infosep to support Win file systems self.wincompatible = self.config.getdefaultboolean( "Account "+self.accountname, "maildir-windows-compatible", False) @@ -220,12 +220,9 @@ class MaildirFolder(BaseFolder): # Interface from BaseFolder def cachemessagelist(self): - if self.messagelist is None: + if self.ismessagelistempty(): self.messagelist = self._scanfolder() - def dropmessagelistcache(self): - self.messagelist = None - # Interface from BaseFolder def getmessagelist(self): return self.messagelist