/head: changeset 92

Made several fixes for 2.0.8
This commit is contained in:
jgoerzen 2002-07-11 04:31:39 +01:00
parent f8c2be1df7
commit 120076256f
3 changed files with 36 additions and 18 deletions

View File

@ -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 <jgoerzen@complete.org> Wed, 10 Jul 2002 12:29:30 -0500
offlineimap (2.0.7) unstable; urgency=low offlineimap (2.0.7) unstable; urgency=low
* Fixed imaplib.py to work better with read-only folders. * Fixed imaplib.py to work better with read-only folders.

View File

@ -45,30 +45,25 @@ class IMAPFolder(BaseFolder):
def getuidvalidity(self): def getuidvalidity(self):
imapobj = self.imapserver.acquireconnection() imapobj = self.imapserver.acquireconnection()
x = None
readonlysave = imapobj.is_readonly
imapobj.is_readonly = 1
try: 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: finally:
self.imapserver.releaseconnection(imapobj) self.imapserver.releaseconnection(imapobj)
imapobj.is_readonly = readonlysave
uidstring = imaputil.imapsplit(x)[1]
return long(imaputil.flagsplit(uidstring)[1])
def cachemessagelist(self): def cachemessagelist(self):
imapobj = self.imapserver.acquireconnection() imapobj = self.imapserver.acquireconnection()
self.messagelist = {}
try: try:
self.messagelist = {} # Primes untagged_responses
response = imapobj.status(self.getfullname(), '(MESSAGES)')[1][0] imapobj.select(self.getfullname(), readonly = 1)
result = imaputil.imapsplit(response)[1] maxmsgid = long(imapobj.untagged_responses['EXISTS'][0])
maxmsgid = long(imaputil.flags2hash(result)['MESSAGES']) if maxmsgid < 1:
if (maxmsgid < 1): # No messages; return
# No messages? return.
return return
# Needed for fetch below
imapobj.select(self.getfullname(), readonly = 1)
# Now, get the flags and UIDs for these. # Now, get the flags and UIDs for these.
response = imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1] response = imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1]
finally: finally:
@ -98,6 +93,8 @@ class IMAPFolder(BaseFolder):
def savemessage(self, uid, content, flags): def savemessage(self, uid, content, flags):
imapobj = self.imapserver.acquireconnection() imapobj = self.imapserver.acquireconnection()
try: try:
imapobj.select(self.getfullname()) # Needed for search
# This backend always assigns a new uid, so the uid arg is ignored. # 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. # In order to get the new uid, we need to save off the message ID.

View File

@ -106,9 +106,17 @@ class MaildirFolder(BaseFolder):
if flagmatch: if flagmatch:
flags = [x for x in flagmatch.group(1)] flags = [x for x in flagmatch.group(1)]
flags.sort() flags.sort()
self.messagelist[uid] = {'uid': uid, if 'T' in flags:
'flags': flags, # Message is marked for deletion; just delete it now.
'filename': file} # 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): def getmessagelist(self):
return self.messagelist return self.messagelist