diff --git a/Changelog.rst b/Changelog.rst index db4eb24..e541358 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -4,6 +4,13 @@ ChangeLog :website: http://offlineimap.org + +OfflineIMAP v6.5.6 (YYYY-MM-DD) +=============================== + +* Add knob to invoke folderfilter dynamically on each sync (GitHub#73) + + OfflineIMAP v6.5.5 (2013-10-07) =============================== diff --git a/offlineimap.conf b/offlineimap.conf index 836d075..0a8d44c 100644 --- a/offlineimap.conf +++ b/offlineimap.conf @@ -540,6 +540,12 @@ remoteuser = username # # nametrans = lambda foldername: re.sub('^INBOX\.*', '.', foldername) +# Determines if folderfilter will be invoked on each run +# (dynamic folder filtering) or filtering status will be determined +# at startup (default behaviour). +# +# dynamic_folderfilter = False + # You can specify which folders to sync using the folderfilter # setting. You can provide any python function (e.g. a lambda function) # which will be invoked for each foldername. If the filter function diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index f8b79b4..b26e169 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -33,11 +33,8 @@ class BaseFolder(object): :para repository: Repository() in which the folder is. """ self.ui = getglobalui() - """Should this folder be included in syncing?""" - self._sync_this = repository.should_sync_folder(name) - if not self._sync_this: - self.ui.debug('', "Filtering out '%s'[%s] due to folderfilter" \ - % (name, repository)) + # Save original name for folderfilter operations + self.ffilter_name = name # Top level dir name is always '' self.name = name if not name == self.getsep() else '' self.repository = repository @@ -47,6 +44,7 @@ class BaseFolder(object): # return for the top-level dir. if self.visiblename == self.getsep(): self.visiblename = '' + self.config = repository.getconfig() utime_from_message_global = \ self.config.getdefaultboolean("general", @@ -56,6 +54,19 @@ class BaseFolder(object): self.config.getdefaultboolean(repo, "utime_from_message", utime_from_message_global) + # Determine if we're running static or dynamic folder filtering + # and check filtering status + self._dynamic_folderfilter = \ + self.config.getdefaultboolean(repo, "dynamic_folderfilter", False) + self._sync_this = repository.should_sync_folder(self.ffilter_name) + if self._dynamic_folderfilter: + self.ui.debug('', "Running dynamic folder filtering on '%s'[%s]" \ + % (self.ffilter_name, repository)) + elif not self._sync_this: + self.ui.debug('', "Filtering out '%s'[%s] due to folderfilter" \ + % (self.ffilter_name, repository)) + + def getname(self): """Returns name""" return self.name @@ -71,7 +82,10 @@ class BaseFolder(object): @property def sync_this(self): """Should this folder be synced or is it e.g. filtered out?""" - return self._sync_this + if not self._dynamic_folderfilter: + return self._sync_this + else: + return this.repository.should_sync_folder(self.ffilter_name) @property def utime_from_message(self):