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:
parent
baee2b6fd9
commit
9e63fa3784
@ -248,8 +248,17 @@ class BaseFolder(object):
|
|||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def ismessagelistempty(self):
|
||||||
|
"""Empty everythings we know about messages."""
|
||||||
|
|
||||||
|
if len(self.messagelist.keys()) < 1:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def dropmessagelistcache(self):
|
def dropmessagelistcache(self):
|
||||||
raise NotImplementedException
|
"""Empty everythings we know about messages."""
|
||||||
|
|
||||||
|
self.messagelist = {}
|
||||||
|
|
||||||
def getmessagelist(self):
|
def getmessagelist(self):
|
||||||
"""Gets the current message list.
|
"""Gets the current message list.
|
||||||
|
@ -65,7 +65,7 @@ class GmailMaildirFolder(MaildirFolder):
|
|||||||
|
|
||||||
|
|
||||||
def cachemessagelist(self):
|
def cachemessagelist(self):
|
||||||
if self.messagelist is None:
|
if self.ismessagelistempty():
|
||||||
self.messagelist = self._scanfolder()
|
self.messagelist = self._scanfolder()
|
||||||
|
|
||||||
# Get mtimes
|
# Get mtimes
|
||||||
|
@ -48,7 +48,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
self.expunge = repository.getexpunge()
|
self.expunge = repository.getexpunge()
|
||||||
self.root = None # imapserver.root
|
self.root = None # imapserver.root
|
||||||
self.imapserver = imapserver
|
self.imapserver = imapserver
|
||||||
self.messagelist = None
|
self.messagelist = {}
|
||||||
self.randomgenerator = random.Random()
|
self.randomgenerator = random.Random()
|
||||||
#self.ui is set in BaseFolder
|
#self.ui is set in BaseFolder
|
||||||
self.imap_query = ['BODY.PEEK[]']
|
self.imap_query = ['BODY.PEEK[]']
|
||||||
@ -249,7 +249,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime}
|
self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime}
|
||||||
|
|
||||||
def dropmessagelistcache(self):
|
def dropmessagelistcache(self):
|
||||||
self.messagelist = None
|
self.messagelist = {}
|
||||||
|
|
||||||
# Interface from BaseFolder
|
# Interface from BaseFolder
|
||||||
def getmessagelist(self):
|
def getmessagelist(self):
|
||||||
|
@ -155,9 +155,6 @@ class LocalStatusFolder(BaseFolder):
|
|||||||
self.readstatus(cachefd)
|
self.readstatus(cachefd)
|
||||||
cachefd.close()
|
cachefd.close()
|
||||||
|
|
||||||
def dropmessagelistcache(self):
|
|
||||||
self.messagelist = None
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Save changed data to disk. For this backend it is the same as saveall."""
|
"""Save changed data to disk. For this backend it is the same as saveall."""
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ class LocalStatusSQLiteFolder(BaseFolder):
|
|||||||
self.messagelist[uid]['mtime'] = row[2]
|
self.messagelist[uid]['mtime'] = row[2]
|
||||||
|
|
||||||
def dropmessagelistcache(self):
|
def dropmessagelistcache(self):
|
||||||
self.messagelist = None
|
self.messagelist = {}
|
||||||
|
|
||||||
# Interface from LocalStatusFolder
|
# Interface from LocalStatusFolder
|
||||||
def save(self):
|
def save(self):
|
||||||
|
@ -63,7 +63,7 @@ class MaildirFolder(BaseFolder):
|
|||||||
super(MaildirFolder, self).__init__(name, repository)
|
super(MaildirFolder, self).__init__(name, repository)
|
||||||
self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
|
self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
|
||||||
self.root = root
|
self.root = root
|
||||||
self.messagelist = None
|
self.messagelist = {}
|
||||||
# check if we should use a different infosep to support Win file systems
|
# check if we should use a different infosep to support Win file systems
|
||||||
self.wincompatible = self.config.getdefaultboolean(
|
self.wincompatible = self.config.getdefaultboolean(
|
||||||
"Account "+self.accountname, "maildir-windows-compatible", False)
|
"Account "+self.accountname, "maildir-windows-compatible", False)
|
||||||
@ -220,12 +220,9 @@ class MaildirFolder(BaseFolder):
|
|||||||
|
|
||||||
# Interface from BaseFolder
|
# Interface from BaseFolder
|
||||||
def cachemessagelist(self):
|
def cachemessagelist(self):
|
||||||
if self.messagelist is None:
|
if self.ismessagelistempty():
|
||||||
self.messagelist = self._scanfolder()
|
self.messagelist = self._scanfolder()
|
||||||
|
|
||||||
def dropmessagelistcache(self):
|
|
||||||
self.messagelist = None
|
|
||||||
|
|
||||||
# Interface from BaseFolder
|
# Interface from BaseFolder
|
||||||
def getmessagelist(self):
|
def getmessagelist(self):
|
||||||
return self.messagelist
|
return self.messagelist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user