Drop caches after having processed folders.
This enhances a lot memory consumption when you have many folders to process. Signed-off-by: Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
This commit is contained in:
parent
63e499c6f2
commit
29e9b7ab39
@ -491,3 +491,7 @@ def syncfolder(account, remotefolder, quick):
|
||||
ui.error(e, msg = "ERROR in syncfolder for %s folder %s: %s" % \
|
||||
(account, remotefolder.getvisiblename(),
|
||||
traceback.format_exc()))
|
||||
finally:
|
||||
for folder in ["statusfolder", "localfolder", "remotefolder"]:
|
||||
if folder in locals():
|
||||
locals()[folder].dropmessagelistcache()
|
||||
|
@ -247,6 +247,9 @@ class BaseFolder(object):
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
raise NotImplementedException
|
||||
|
||||
def getmessagelist(self):
|
||||
"""Gets the current message list.
|
||||
You must call cachemessagelist() before calling this function!"""
|
||||
|
@ -250,6 +250,8 @@ class IMAPFolder(BaseFolder):
|
||||
rtime = imaplibutil.Internaldate2epoch(messagestr)
|
||||
self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime}
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
self.messagelist = None
|
||||
|
||||
# Interface from BaseFolder
|
||||
def getmessagelist(self):
|
||||
|
@ -161,6 +161,8 @@ class LocalStatusFolder(BaseFolder):
|
||||
self.readstatus(file)
|
||||
file.close()
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
self.messagelist = None
|
||||
|
||||
def save(self):
|
||||
"""Save changed data to disk. For this backend it is the same as saveall."""
|
||||
|
@ -203,6 +203,9 @@ class LocalStatusSQLiteFolder(BaseFolder):
|
||||
self.messagelist[uid]['labels'] = labels
|
||||
self.messagelist[uid]['mtime'] = row[2]
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
self.messagelist = None
|
||||
|
||||
# Interface from LocalStatusFolder
|
||||
def save(self):
|
||||
pass
|
||||
|
@ -220,6 +220,9 @@ class MaildirFolder(BaseFolder):
|
||||
if self.messagelist is None:
|
||||
self.messagelist = self._scanfolder()
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
self.messagelist = None
|
||||
|
||||
# Interface from BaseFolder
|
||||
def getmessagelist(self):
|
||||
return self.messagelist
|
||||
|
@ -125,6 +125,9 @@ class MappedIMAPFolder(IMAPFolder):
|
||||
finally:
|
||||
self.maplock.release()
|
||||
|
||||
def dropmessagelistcache(self):
|
||||
self._mb.dropmessagelistcache()
|
||||
|
||||
# Interface from BaseFolder
|
||||
def uidexists(self, ruid):
|
||||
"""Checks if the (remote) UID exists in this Folder"""
|
||||
|
Loading…
Reference in New Issue
Block a user