Fix error handling in folder.Base.copymessageto()
This is a bug fix on several levels. 1) We were lacking the import of OfflineImapError. 2) OfflineImap.ERROR.MESSAGE was misspelled as ERROR.Message. 3) COntinuing with the next message only worked in single-thread mode (using debug) and not in multi-thread mode. The reason is that we were invoking a new thread and catching Exceptions in the main thread. But python immediately aborts if an Exception bubbles up to a thread start. This was fixed by catching exceptions directly in copymessageto() which is the new thread, rather than catching them in the main thread. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
634b6cd49e
commit
9f23fea74e
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
from offlineimap import threadutil
|
from offlineimap import threadutil
|
||||||
from offlineimap.ui import getglobalui
|
from offlineimap.ui import getglobalui
|
||||||
|
from offlineimap.error import OfflineImapError
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
from sys import exc_info
|
from sys import exc_info
|
||||||
@ -233,6 +234,7 @@ class BaseFolder(object):
|
|||||||
if register: # output that we start a new thread
|
if register: # output that we start a new thread
|
||||||
self.ui.registerthread(self.getaccountname())
|
self.ui.registerthread(self.getaccountname())
|
||||||
|
|
||||||
|
try:
|
||||||
message = None
|
message = None
|
||||||
flags = self.getmessageflags(uid)
|
flags = self.getmessageflags(uid)
|
||||||
rtime = self.getmessagetime(uid)
|
rtime = self.getmessagetime(uid)
|
||||||
@ -279,6 +281,16 @@ class BaseFolder(object):
|
|||||||
dstfolder.getvisiblename(),
|
dstfolder.getvisiblename(),
|
||||||
newuid),
|
newuid),
|
||||||
OfflineImapError.ERROR.MESSAGE)
|
OfflineImapError.ERROR.MESSAGE)
|
||||||
|
except OfflineImapError, e:
|
||||||
|
if e.severity > OfflineImapError.ERROR.MESSAGE:
|
||||||
|
raise # buble severe errors up
|
||||||
|
self.ui.error(e, exc_info()[2])
|
||||||
|
except Exception, e:
|
||||||
|
self.ui.error(e, "Copying message %s [acc: %s]:\n %s" %\
|
||||||
|
(uid, self.getaccountname(),
|
||||||
|
traceback.format_exc()))
|
||||||
|
raise #raise on unknown errors, so we can fix those
|
||||||
|
|
||||||
|
|
||||||
def syncmessagesto_copy(self, dstfolder, statusfolder):
|
def syncmessagesto_copy(self, dstfolder, statusfolder):
|
||||||
"""Pass1: Copy locally existing messages not on the other side
|
"""Pass1: Copy locally existing messages not on the other side
|
||||||
@ -297,7 +309,7 @@ class BaseFolder(object):
|
|||||||
statusfolder.uidexists(uid),
|
statusfolder.uidexists(uid),
|
||||||
self.getmessageuidlist())
|
self.getmessageuidlist())
|
||||||
for uid in copylist:
|
for uid in copylist:
|
||||||
try:
|
# exceptions are caught in copymessageto()
|
||||||
if self.suggeststhreads():
|
if self.suggeststhreads():
|
||||||
self.waitforthread()
|
self.waitforthread()
|
||||||
thread = threadutil.InstanceLimitedThread(\
|
thread = threadutil.InstanceLimitedThread(\
|
||||||
@ -312,15 +324,6 @@ class BaseFolder(object):
|
|||||||
else:
|
else:
|
||||||
self.copymessageto(uid, dstfolder, statusfolder,
|
self.copymessageto(uid, dstfolder, statusfolder,
|
||||||
register = 0)
|
register = 0)
|
||||||
except OfflineImapError, e:
|
|
||||||
if e.severity > OfflineImapError.ERROR.Message:
|
|
||||||
raise # buble severe errors up
|
|
||||||
self.ui.error(e, exc_info()[2])
|
|
||||||
except Exception, e:
|
|
||||||
self.ui.error(e, "Copying message %s [acc: %s]:\n %s" %\
|
|
||||||
(uid, self.getaccountname(),
|
|
||||||
traceback.format_exc()))
|
|
||||||
raise #raise on unknown errors, so we can fix those
|
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user