folder: Implement helper functions uidexists() and getmessageuidlist()
More convenient way to test if a certain uid exists and getting a list of all uids. Also, the SQL backend will have efficient overrides for these methods. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
4d352a528a
commit
6c6fdfc769
@ -139,6 +139,15 @@ class BaseFolder:
|
|||||||
You must call cachemessagelist() before calling this function!"""
|
You must call cachemessagelist() before calling this function!"""
|
||||||
raise NotImplementedException
|
raise NotImplementedException
|
||||||
|
|
||||||
|
def uidexists(self, uid):
|
||||||
|
"""Returns True if uid exists"""
|
||||||
|
return uid in self.getmessagelist()
|
||||||
|
|
||||||
|
def getmessageuidlist(self):
|
||||||
|
"""Gets a list of UIDs.
|
||||||
|
You may have to call cachemessagelist() before calling this function!"""
|
||||||
|
return self.getmessagelist().keys()
|
||||||
|
|
||||||
def getmessagecount(self):
|
def getmessagecount(self):
|
||||||
"""Gets the number of messages."""
|
"""Gets the number of messages."""
|
||||||
return len(self.getmessagelist())
|
return len(self.getmessagelist())
|
||||||
@ -267,7 +276,7 @@ class BaseFolder:
|
|||||||
:param dstfolder: A BaseFolder-derived instance
|
:param dstfolder: A BaseFolder-derived instance
|
||||||
:param statusfolder: A LocalStatusFolder instance"""
|
:param statusfolder: A LocalStatusFolder instance"""
|
||||||
|
|
||||||
uidlist = [uid for uid in self.getmessagelist().keys() if uid < 0]
|
uidlist = [uid for uid in self.getmessageuidlist() if uid < 0]
|
||||||
threads = []
|
threads = []
|
||||||
|
|
||||||
for uid in uidlist:
|
for uid in uidlist:
|
||||||
@ -351,8 +360,8 @@ class BaseFolder:
|
|||||||
threads = []
|
threads = []
|
||||||
|
|
||||||
copylist = filter(lambda uid: uid>=0 and not \
|
copylist = filter(lambda uid: uid>=0 and not \
|
||||||
uid in statusfolder.getmessagelist(),
|
statusfolder.uidexists(uid),
|
||||||
self.getmessagelist().keys())
|
self.getmessageuidlist())
|
||||||
for uid in copylist:
|
for uid in copylist:
|
||||||
if self.suggeststhreads():
|
if self.suggeststhreads():
|
||||||
self.waitforthread()
|
self.waitforthread()
|
||||||
@ -378,8 +387,8 @@ class BaseFolder:
|
|||||||
that were deleted in 'self'. Delete those from dstfolder and
|
that were deleted in 'self'. Delete those from dstfolder and
|
||||||
statusfolder."""
|
statusfolder."""
|
||||||
deletelist = filter(lambda uid: uid>=0 \
|
deletelist = filter(lambda uid: uid>=0 \
|
||||||
and not uid in self.getmessagelist(),
|
and not self.uidexists(uid),
|
||||||
statusfolder.getmessagelist().keys())
|
statusfolder.getmessageuidlist())
|
||||||
if len(deletelist):
|
if len(deletelist):
|
||||||
self.ui.deletingmessages(deletelist, [dstfolder])
|
self.ui.deletingmessages(deletelist, [dstfolder])
|
||||||
# delete in statusfolder first to play safe. In case of abort, we
|
# delete in statusfolder first to play safe. In case of abort, we
|
||||||
@ -400,10 +409,10 @@ class BaseFolder:
|
|||||||
# bulk, rather than one call per message.
|
# bulk, rather than one call per message.
|
||||||
addflaglist = {}
|
addflaglist = {}
|
||||||
delflaglist = {}
|
delflaglist = {}
|
||||||
for uid in self.getmessagelist().keys():
|
for uid in self.getmessageuidlist():
|
||||||
# Ignore messages with negative UIDs missed by pass 1
|
# Ignore messages with negative UIDs missed by pass 1
|
||||||
# also don't do anything if the message has been deleted remotely
|
# also don't do anything if the message has been deleted remotely
|
||||||
if uid < 0 or not uid in dstfolder.getmessagelist():
|
if uid < 0 or not dstfolder.uidexists(uid):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
selfflags = self.getmessageflags(uid)
|
selfflags = self.getmessageflags(uid)
|
||||||
|
Loading…
Reference in New Issue
Block a user