add sync_this variable to all Folder() instances
This variable shows if this folder should be synced or is disabled due to a folderfilter statement. This lets us distinguish between a non-existent folder and one that has been filtered out. Previously any filtered folder would simply appear to be non-existing. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
32ca20d0da
commit
8ba17c5bd1
@ -274,6 +274,10 @@ class SyncableAccount(Account):
|
||||
|
||||
# iterate through all folders on the remote repo and sync
|
||||
for remotefolder in remoterepos.getfolders():
|
||||
if not remotefolder.sync_this:
|
||||
self.ui.debug('', "Not syncing filtered remote folder '%s'"
|
||||
"[%s]" % (remotefolder, remoterepos))
|
||||
continue # Filtered out remote folder
|
||||
thread = InstanceLimitedThread(\
|
||||
instancename = 'FOLDER_' + self.remoterepos.getname(),
|
||||
target = syncfolder,
|
||||
@ -323,7 +327,9 @@ class SyncableAccount(Account):
|
||||
def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
||||
statusrepos, quick):
|
||||
"""This function is called as target for the
|
||||
InstanceLimitedThread invokation in SyncableAccount."""
|
||||
InstanceLimitedThread invokation in SyncableAccount.
|
||||
|
||||
Filtered folders on the remote side will not invoke this function."""
|
||||
ui = getglobalui()
|
||||
ui.registerthread(accountname)
|
||||
try:
|
||||
@ -331,6 +337,14 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
|
||||
localfolder = localrepos.\
|
||||
getfolder(remotefolder.getvisiblename().\
|
||||
replace(remoterepos.getsep(), localrepos.getsep()))
|
||||
|
||||
#Filtered folders on the remote side will not invoke this
|
||||
#function, but we need to NOOP if the local folder is filtered
|
||||
#out too:
|
||||
if not localfolder.sync_this:
|
||||
ui.debug('', "Not syncing filtered local folder '%s'" \
|
||||
% localfolder)
|
||||
return
|
||||
# Write the mailboxes
|
||||
mbnames.add(accountname, localfolder.getvisiblename())
|
||||
|
||||
|
@ -33,6 +33,8 @@ class BaseFolder(object):
|
||||
:para name: Path & name of folder minus root or reference
|
||||
:para repository: Repository() in which the folder is.
|
||||
"""
|
||||
self.sync_this = True
|
||||
"""Should this folder be included in syncing?"""
|
||||
self.ui = getglobalui()
|
||||
self.name = name
|
||||
self.repository = repository
|
||||
|
@ -295,12 +295,14 @@ class IMAPRepository(BaseRepository):
|
||||
if '\\noselect' in flaglist:
|
||||
continue
|
||||
foldername = imaputil.dequote(name)
|
||||
if not self.folderfilter(foldername):
|
||||
self.ui.debug('imap',"Filtering out '%s' due to folderfilter" %\
|
||||
foldername)
|
||||
continue
|
||||
retval.append(self.getfoldertype()(self.imapserver, foldername,
|
||||
self))
|
||||
# filter out the folder?
|
||||
if not self.folderfilter(foldername):
|
||||
self.ui.debug('imap', "Filtering out '%s'[%s] due to folderfilt"
|
||||
"er" % (foldername, self))
|
||||
retval[-1].sync_this = False
|
||||
# Add all folderincludes
|
||||
if len(self.folderincludes):
|
||||
imapobj = self.imapserver.acquireconnection()
|
||||
try:
|
||||
@ -322,7 +324,7 @@ class IMAPRepository(BaseRepository):
|
||||
|
||||
retval.sort(lambda x, y: self.foldersort(x.getvisiblename(), y.getvisiblename()))
|
||||
self.folders = retval
|
||||
return retval
|
||||
return self.folders
|
||||
|
||||
def makefolder(self, foldername):
|
||||
#if self.getreference() != '""':
|
||||
|
Loading…
Reference in New Issue
Block a user