offlineimap rev 553

"Automatic Subversion Change Mailer" <[email protected]> Tue, 5 Aug 2003 14:52:42 -0500 (CDT)
Newsgroups gmane.mail.imap.offlineimap.subversion
Message-ID <[email protected]>
You are receiving this message because
all commits get sent to this address.

Author: jgoerzen
Date: 2003-08-05 14:52:25 -0500 (Tue, 05 Aug 2003)
New Revision: 553

Modified:
  offlineimap/branches/twisted/offlineimap/folder/IMAP.py
  offlineimap/branches/twisted/offlineimap/imapserver.py
  offlineimap/branches/twisted/twistedfixes/imap4.py

Log:
Now appears to be able to handle deleted messages properly.


Diff:
Modified: offlineimap/branches/twisted/offlineimap/folder/IMAP.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/folder/IMAP.py	2003-08-05 19:34:03 UTC (rev 552)
+++ offlineimap/branches/twisted/offlineimap/folder/IMAP.py	2003-08-05 19:52:25 UTC (rev 553)
@@ -191,6 +191,7 @@
         ui.debug('imap', 'savemessage_step1: called')
         d = imapobj.select(self.getfullname())
         d.addCallback(self._savemessage_step2, imapobj, uid, content, flags)
+        return d
 
     def _savemessage_step2(self, ignore, imapobj, uid, content, flags):
         # This backend always assigns a new uid, so the uid arg is ignored.
@@ -331,25 +332,21 @@
                       imapobj, operation, uidlist, flags)
         return d
 
-    def _processmessagesflags_step2(self, result, imapobj, operation,
+    def _processmessagesflags_step2(self, r, imapobj, operation,
                                     uidlist, flags):
-        raise NotImplementedError, "RESULT IS: " + str(result)
-        r = r[1]
         # Some IMAP servers do not always return a result.  Therefore,
         # only update the ones that it talks about, and manually fix
         # the others.
         needupdate = copy(uidlist)
-        for result in r:
-            if result == None:
+        for result in r.values():
+            if not (type(result) == type({}) and \
+                    result.has_key('FLAGS') and \
+                    result.has_key('UID')):
                 # Compensate for servers that don't return anything from
                 # STORE.
                 continue
-            attributehash = imaputil.flags2hash(imaputil.imapsplit(result)[1])
-            if not ('UID' in attributehash and 'FLAGS' in attributehash):
-                # Compensate for servers that don't return a UID attribute.
-                continue
-            flags = attributehash['FLAGS']
-            uid = long(attributehash['UID'])
+            flags = result['FLAGS']
+            uid = long(result['UID'])
             self.messagelist[uid]['flags'] = imaputil.flagsimap2maildir(flags)
             try:
                 needupdate.remove(uid)
@@ -366,6 +363,9 @@
                     if flag in self.messagelist[uid]['flags']:
                         self.messagelist[uid]['flags'].remove(flag)
 
+        # For chaining to expunge!
+        return imapobj
+
     def deletemessage(self, uid):
         return self.deletemessages_noconvert([uid])
 
@@ -380,12 +380,16 @@
 
         dflags = self.addmessagesflags_noconvert(uidlist, ['T'])
         if self.expunge:
-            dflags.addCallback(lambda x: self.expunge())
+            # It returns an imapobj, which gets passed along.
+            # Otherwise, it would hang on to the imapobj, and we'd
+            # get a potential deadlock situation due to it not being
+            # released until expunge has acquired it.
+            dflags.addCallback(self._doexpunge_acquired)
         return dflags
 
-    def _expunge_acquired(self, imapobj):
+    def _doexpunge_acquired(self, imapobj):
         d = imapobj.select(self.getfullname())
-        d.addCallback(lambda ignore, io: io.expunge(), imapobj)
+        d.addCallback(lambda ignore: imapobj.expunge())
         return d
 
     def deletemessage_noconvert_worker(self, ignore, uidlist):

Modified: offlineimap/branches/twisted/offlineimap/imapserver.py
==============================================================================
--- offlineimap/branches/twisted/offlineimap/imapserver.py	2003-08-05 19:34:03 UTC (rev 552)
+++ offlineimap/branches/twisted/offlineimap/imapserver.py	2003-08-05 19:52:25 UTC (rev 553)
@@ -20,7 +20,8 @@
 from threading import *
 import thread, hmac, os
 from twisted.internet import defer, protocol, reactor
-from twisted.protocols.imap4 import IMAP4Client
+#from twisted.protocols.imap4 import IMAP4Client
+from twistedfixes.imap4 import IMAP4Client
 from twisted.internet.ssl import ClientContextFactory
 from imaputil import rd
 

Modified: offlineimap/branches/twisted/twistedfixes/imap4.py
==============================================================================
--- offlineimap/branches/twisted/twistedfixes/imap4.py	2003-08-05 19:34:03 UTC (rev 552)
+++ offlineimap/branches/twisted/twistedfixes/imap4.py	2003-08-05 19:52:25 UTC (rev 553)
@@ -2858,7 +2858,7 @@
         store = uid and 'UID STORE' or 'STORE'
         args = ' '.join((messages, cmd, '(%s)' % ' '.join(flags)))
         d = self.sendCommand(Command(store, args, wantResponse=('FETCH',)))
-        d.addCallback(self.__cbFetch, lookFor='FLAGS')
+        d.addCallback(self.__cbFetch)
         return d
     
     def copy(self, messages, mailbox, uid):