]> code.delx.au - offlineimap/commitdiff
New option to only work with subscribed folders
authorJohn Goerzen <jgoerzen@complete.org>
Wed, 1 Oct 2008 05:33:57 +0000 (00:33 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Wed, 1 Oct 2008 05:33:57 +0000 (00:33 -0500)
Patch from Sean Finney, slightly modified by John Goerzen to change
name of config file option

fixes deb#499588

offlineimap.conf
offlineimap/repository/IMAP.py

index 6389905c4dae98e35085089cd3d2849dc8129166..011c33e1941629c2e12a95b11c70e23ec982585e 100644 (file)
@@ -212,6 +212,10 @@ type = Maildir
 
 localfolders = ~/Test
 
+# Specify whether to process all mail folders on the server, or only
+# those listed as "subscribed".
+subscribedonly = no
+
 # You can specify the "path separator character" used for your Maildir
 # folders.  This is inserted in-between the components of the tree.
 # It defaults to ".".  If you want your Maildir folders to be nested,
index 8c5f46942b54c406fb04d97e3b570ea4d6d5023e..a9d73438edb89b249186bd72a2c1ca282868bcdf 100644 (file)
@@ -192,8 +192,13 @@ class IMAPRepository(BaseRepository):
             return self.folders
         retval = []
         imapobj = self.imapserver.acquireconnection()
+        # check whether to list all folders, or subscribed only
+        listfunction = imapobj.list
+        if self.config.has_option(self.getsection(), 'subscribedonly'):
+          if self.getconf('subscribedonly') == "yes":
+            listfunction = imapobj.lsub
         try:
-            listresult = imapobj.list(directory = self.imapserver.reference)[1]
+            listresult = listfunction(directory = self.imapserver.reference)[1]
         finally:
             self.imapserver.releaseconnection(imapobj)
         for string in listresult: