diff --git a/offlineimap.conf b/offlineimap.conf index 6389905..011c33e 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -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, diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 8c5f469..a9d7343 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -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: