set singlethreadperfolder configuration option when in idle mode

Git-reference: https://github.com/OfflineIMAP/offlineimap/issues/376
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-09-20 02:18:41 +02:00
parent bd4b968f1d
commit c287ecb7cc
2 changed files with 9 additions and 1 deletions

View File

@ -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.

View File

@ -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