/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

@ -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.

View File

@ -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