fix: folder/*: never set self.messagelist to None

Empty the list by setting an empty dict.
Introduce BaseFolder().ismessagelistempty().

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2015-02-13 17:02:33 +01:00
parent baee2b6fd9
commit 9e63fa3784
6 changed files with 16 additions and 13 deletions

View File

@ -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.

View File

@ -65,7 +65,7 @@ class GmailMaildirFolder(MaildirFolder):
def cachemessagelist(self):
if self.messagelist is None:
if self.ismessagelistempty():
self.messagelist = self._scanfolder()
# Get mtimes

View File

@ -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):

View File

@ -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."""

View File

@ -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):

View File

@ -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