From c287ecb7cc14f3f579d9d503d568c94d504b3e03 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Tue, 20 Sep 2016 02:18:41 +0200 Subject: [PATCH] set singlethreadperfolder configuration option when in idle mode Git-reference: https://github.com/OfflineIMAP/offlineimap/issues/376 Signed-off-by: Nicolas Sebrecht --- offlineimap.conf | 1 + offlineimap/folder/IMAP.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/offlineimap.conf b/offlineimap.conf index 4006dd3..4c89098 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -987,6 +987,7 @@ remoteuser = username # - maxconnections: to be at least the number of folders you give # - holdconnectionopen: to be true # - keepalive: to be 29 minutes unless you specify otherwise +# - singlethreadperfolder: to be true # # The presynchook and postsynchook are executed for each new synchronisation per # folder. diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 13d1618..7801aa8 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -48,6 +48,7 @@ class IMAPFolder(BaseFolder): name = imaputil.dequote(name) self.sep = imapserver.delim super(IMAPFolder, self).__init__(name, repository) + self.idle_mode = False self.expunge = repository.getexpunge() self.root = None # imapserver.root self.imapserver = imapserver @@ -61,6 +62,8 @@ class IMAPFolder(BaseFolder): # self.copy_ignoreUIDs is used by BaseFolder. self.copy_ignoreUIDs = repository.get_copy_ignore_UIDs( self.getvisiblename()) + if self.repository.getidlefolders() > 0: + self.idle_mode = True def __selectro(self, imapobj, force=False): @@ -79,9 +82,13 @@ class IMAPFolder(BaseFolder): # Interface from BaseFolder def suggeststhreads(self): + singlethreadperfolder_default = False + if self.idle_mode is True: + singlethreadperfolder_default = True + onethread = self.config.getdefaultboolean( "Repository %s"% self.repository.getname(), - "singlethreadperfolder", False) + "singlethreadperfolder", singlethreadperfolder_default) if onethread is True: return False return not globals.options.singlethreading