Do not create folders on readonly repositories
1) Rename the unintuitive repository.syncfoldersto() to sync_folder_structure() 2) We were checking if the local repository is readonly and then turning off any folder creation. But as we can create folders on a remote repository too, we need to be more fine grained here. Just don't create a folder on the repository that is marked readonly=True. This still does not do away with the error message that one currently gets on missing local folders. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
6f361c4d9a
commit
3e28073f98
@ -289,10 +289,10 @@ class SyncableAccount(Account):
|
|||||||
localrepos.getfolders()
|
localrepos.getfolders()
|
||||||
statusrepos.getfolders()
|
statusrepos.getfolders()
|
||||||
|
|
||||||
|
remoterepos.sync_folder_structure(localrepos, statusrepos)
|
||||||
# replicate the folderstructure between REMOTE to LOCAL
|
# replicate the folderstructure between REMOTE to LOCAL
|
||||||
if not localrepos.getconfboolean('readonly', False):
|
if not localrepos.getconfboolean('readonly', False):
|
||||||
self.ui.syncfolders(remoterepos, localrepos)
|
self.ui.syncfolders(remoterepos, localrepos)
|
||||||
remoterepos.syncfoldersto(localrepos, statusrepos)
|
|
||||||
|
|
||||||
# iterate through all folders on the remote repo and sync
|
# iterate through all folders on the remote repo and sync
|
||||||
for remotefolder in remoterepos.getfolders():
|
for remotefolder in remoterepos.getfolders():
|
||||||
|
@ -133,7 +133,7 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin):
|
|||||||
def getfolder(self, foldername):
|
def getfolder(self, foldername):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def syncfoldersto(self, dst_repo, status_repo):
|
def sync_folder_structure(self, dst_repo, status_repo):
|
||||||
"""Syncs the folders in this repository to those in dest.
|
"""Syncs the folders in this repository to those in dest.
|
||||||
|
|
||||||
It does NOT sync the contents of those folders. nametrans rules
|
It does NOT sync the contents of those folders. nametrans rules
|
||||||
@ -158,6 +158,9 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin):
|
|||||||
|
|
||||||
# Find new folders on src_repo.
|
# Find new folders on src_repo.
|
||||||
for src_name, src_folder in src_hash.iteritems():
|
for src_name, src_folder in src_hash.iteritems():
|
||||||
|
# Don't create on dst_repo, if it is readonly
|
||||||
|
if dst_repo.getconfboolean('readonly', False):
|
||||||
|
break
|
||||||
if src_folder.sync_this and not src_name in dst_hash:
|
if src_folder.sync_this and not src_name in dst_hash:
|
||||||
try:
|
try:
|
||||||
dst_repo.makefolder(src_name)
|
dst_repo.makefolder(src_name)
|
||||||
@ -171,6 +174,10 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin):
|
|||||||
status_repo.getsep()))
|
status_repo.getsep()))
|
||||||
# Find new folders on dst_repo.
|
# Find new folders on dst_repo.
|
||||||
for dst_name, dst_folder in dst_hash.iteritems():
|
for dst_name, dst_folder in dst_hash.iteritems():
|
||||||
|
if self.getconfboolean('readonly', False):
|
||||||
|
# Don't create missing folder on readonly repo.
|
||||||
|
break
|
||||||
|
|
||||||
if dst_folder.sync_this and not dst_name in src_hash:
|
if dst_folder.sync_this and not dst_name in src_hash:
|
||||||
# nametrans sanity check!
|
# nametrans sanity check!
|
||||||
# Does nametrans back&forth lead to identical names?
|
# Does nametrans back&forth lead to identical names?
|
||||||
@ -202,7 +209,6 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin):
|
|||||||
src_repo, newdst_name),
|
src_repo, newdst_name),
|
||||||
OfflineImapError.ERROR.REPO)
|
OfflineImapError.ERROR.REPO)
|
||||||
# end sanity check, actually create the folder
|
# end sanity check, actually create the folder
|
||||||
|
|
||||||
try:
|
try:
|
||||||
src_repo.makefolder(newsrc_name)
|
src_repo.makefolder(newsrc_name)
|
||||||
src_haschanged = True # Need to refresh list
|
src_haschanged = True # Need to refresh list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user