Folder: Force top-level folder visiblename to ''

nametrans rules can lead to different visiblename names for the
top-level directory, specifically both '.' and '' (the latter was
recently introduced). However, we need to be able to compare folder
names to see if we need to create a new directory or whether a directory
already exists, so we need to be able to compare a repositories
visiblename (=transposed via nametrans rule) with another folder.

To make the top-level directory comparison happen, we enforce a
top-level name of '', so that comparisons work.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-09-23 14:27:25 +02:00
parent 275dbfa3fb
commit e30ae53b2a

View File

@ -39,6 +39,11 @@ class BaseFolder(object):
self.name = name
self.repository = repository
self.visiblename = repository.nametrans(name)
# In case the visiblename becomes '.' (top-level) we use '' as
# that is the name that e.g. the Maildir scanning will return
# for the top-level dir.
if self.visiblename == '.':
self.visiblename = ''
self.config = repository.getconfig()
def getname(self):