[PATCH 12/17] Use new getmessagecount getmessageuidlist and uidexists functions
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon Nov 29 16:02:20 GMT 2010
Where appropriate
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
offlineimap/folder/IMAP.py | 6 +++---
offlineimap/folder/Maildir.py | 10 +++++++++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py
index b4fa791..6ad9e82 100644
--- a/offlineimap/folder/IMAP.py
+++ b/offlineimap/folder/IMAP.py
@@ -91,7 +91,7 @@ class IMAPFolder(BaseFolder):
return True
# Different number of messages than last time?
- if maxmsgid != len(statusfolder.getmessagelist()):
+ if maxmsgid != statusfolder.getmessagecount():
return True
if maxmsgid < 1:
@@ -109,7 +109,7 @@ class IMAPFolder(BaseFolder):
if not options.has_key('UID'):
return True
uid = long(options['UID'])
- saveduids = statusfolder.getmessagelist().keys()
+ saveduids = statusfolder.getmessageuidlist()
saveduids.sort()
if uid != saveduids[-1]:
return True
@@ -465,7 +465,7 @@ class IMAPFolder(BaseFolder):
def deletemessages_noconvert(self, uidlist):
# Weed out ones not in self.messagelist
- uidlist = [uid for uid in uidlist if uid in self.messagelist]
+ uidlist = [uid for uid in uidlist if self.uidexists(uid)]
if not len(uidlist):
return
diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
index c93fcc1..09a9a90 100644
--- a/offlineimap/folder/Maildir.py
+++ b/offlineimap/folder/Maildir.py
@@ -291,8 +291,16 @@ class MaildirFolder(BaseFolder):
assert final_dir != tmpdir
def deletemessage(self, uid):
- if not uid in self.messagelist:
+ """Unlinks a message file from the Maildir.
+
+ :param uid: UID of a mail message
+ :type uid: String
+ :return: Nothing, or an Exception if UID but no corresponding file
+ found.
+ """
+ if not self.uidexists(uid):
return
+
filename = self.messagelist[uid]['filename']
try:
os.unlink(filename)
--
1.7.1
More information about the OfflineIMAP-project
mailing list