[PATCH 3/3] Catch folderfilter errors in repository.IMAP.getfolders()

Sebastian Spaeth Sebastian at SSpaeth.de
Tue Jun 14 10:52:06 BST 2011


Rather than throwing ValueError, we now properly throw OfflineImapError
when selecting a folder in folderincludes. So we also need to catch
OfflineImapErrors here. If they are of severity FOLDER, just ignore the
invalid folder and continue. If the error is more severe, bubble it up.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
 offlineimap/repository/IMAP.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py
index 82d9e32..9be7747 100644
--- a/offlineimap/repository/IMAP.py
+++ b/offlineimap/repository/IMAP.py
@@ -24,6 +24,7 @@ from threading import Event
 import re
 import types
 import os
+import sys
 import netrc
 import errno
 
@@ -307,7 +308,12 @@ class IMAPRepository(BaseRepository):
                 for foldername in self.folderincludes:
                     try:
                         imapobj.select(foldername, readonly = 1)
-                    except ValueError:
+                    except OfflineImapError, e:
+                        # couldn't select this folderinclude, so ignore folder.
+                        if e.severity > OfflineImapError.ERROR.FOLDER:
+                            raise
+                        self.ui.error(e, sys.exc_traceback,
+                                      'Invalid folderinclude(?):')
                         continue
                     retval.append(self.getfoldertype()(self.imapserver,
                                                        foldername,
-- 
1.7.4.1





More information about the OfflineIMAP-project mailing list