From 120076256fabef432446048a2d8ecbe2990334fa Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Thu, 11 Jul 2002 04:31:39 +0100 Subject: [PATCH] /head: changeset 92 Made several fixes for 2.0.8 --- head/debian/changelog | 13 +++++++++++++ head/offlineimap/folder/IMAP.py | 27 ++++++++++++--------------- head/offlineimap/folder/Maildir.py | 14 +++++++++++--- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/head/debian/changelog b/head/debian/changelog index 8f64694..24c2e6f 100644 --- a/head/debian/changelog +++ b/head/debian/changelog @@ -1,3 +1,16 @@ +offlineimap (2.0.8) unstable; urgency=low + + * Modified the IMAP folder to use SELECT rather than STATUS more often. + Makes the code more robust; handles better with read-only folders; + and runs faster, especially for non-threaded useres, where it + may eliminate up to 2-3 commands per folder. + * Made sure IMAP folder savemessage() does a select. This was a possible + bug. + * Modified Maildir folder to unlink messages with T flag in + cachemessagelist() + + -- John Goerzen Wed, 10 Jul 2002 12:29:30 -0500 + offlineimap (2.0.7) unstable; urgency=low * Fixed imaplib.py to work better with read-only folders. diff --git a/head/offlineimap/folder/IMAP.py b/head/offlineimap/folder/IMAP.py index 44f309f..75b0abe 100644 --- a/head/offlineimap/folder/IMAP.py +++ b/head/offlineimap/folder/IMAP.py @@ -45,30 +45,25 @@ class IMAPFolder(BaseFolder): def getuidvalidity(self): imapobj = self.imapserver.acquireconnection() - x = None - readonlysave = imapobj.is_readonly - imapobj.is_readonly = 1 try: - x = imapobj.status(self.getfullname(), '(UIDVALIDITY)')[1][0] + # Primes untagged_responses + imapobj.select(self.getfullname(), readonly = 1) + return long(imapobj.untagged_responses['UIDVALIDITY'][0]) finally: self.imapserver.releaseconnection(imapobj) - imapobj.is_readonly = readonlysave - uidstring = imaputil.imapsplit(x)[1] - return long(imaputil.flagsplit(uidstring)[1]) def cachemessagelist(self): imapobj = self.imapserver.acquireconnection() + self.messagelist = {} + try: - self.messagelist = {} - response = imapobj.status(self.getfullname(), '(MESSAGES)')[1][0] - result = imaputil.imapsplit(response)[1] - maxmsgid = long(imaputil.flags2hash(result)['MESSAGES']) - if (maxmsgid < 1): - # No messages? return. + # Primes untagged_responses + imapobj.select(self.getfullname(), readonly = 1) + maxmsgid = long(imapobj.untagged_responses['EXISTS'][0]) + if maxmsgid < 1: + # No messages; return return - # Needed for fetch below - imapobj.select(self.getfullname(), readonly = 1) # Now, get the flags and UIDs for these. response = imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1] finally: @@ -98,6 +93,8 @@ class IMAPFolder(BaseFolder): def savemessage(self, uid, content, flags): imapobj = self.imapserver.acquireconnection() try: + imapobj.select(self.getfullname()) # Needed for search + # This backend always assigns a new uid, so the uid arg is ignored. # In order to get the new uid, we need to save off the message ID. diff --git a/head/offlineimap/folder/Maildir.py b/head/offlineimap/folder/Maildir.py index 1409ada..8fe29d4 100644 --- a/head/offlineimap/folder/Maildir.py +++ b/head/offlineimap/folder/Maildir.py @@ -106,9 +106,17 @@ class MaildirFolder(BaseFolder): if flagmatch: flags = [x for x in flagmatch.group(1)] flags.sort() - self.messagelist[uid] = {'uid': uid, - 'flags': flags, - 'filename': file} + if 'T' in flags: + # Message is marked for deletion; just delete it now. + # Otherwise, the T flag will be propogated to the IMAP + # server, and then expunged there, and then deleted here. + # Might as well just delete it now, to help make things + # more robust. + os.unlink(file) + else: + self.messagelist[uid] = {'uid': uid, + 'flags': flags, + 'filename': file} def getmessagelist(self): return self.messagelist