WIP, revamp how we treat top-level dirs

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-09-30 17:20:11 +02:00
parent ff50585007
commit 78a37f27ef
5 changed files with 11 additions and 8 deletions

View File

@ -37,13 +37,14 @@ class BaseFolder(object):
self.sync_this = True
"""Should this folder be included in syncing?"""
self.ui = getglobalui()
self.name = name
# Top level dir name is always ''
self.name = name if not name == self.getsep() else ''
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 == '.':
# In case the visiblename becomes '.' or '/' (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.getsep():
self.visiblename = ''
self.config = repository.getconfig()

View File

@ -33,10 +33,10 @@ except NameError:
class IMAPFolder(BaseFolder):
def __init__(self, imapserver, name, repository):
name = imaputil.dequote(name)
self.sep = imapserver.delim
super(IMAPFolder, self).__init__(name, repository)
self.expunge = repository.getexpunge()
self.root = None # imapserver.root
self.sep = imapserver.delim
self.imapserver = imapserver
self.messagelist = None
self.randomgenerator = random.Random()

View File

@ -27,8 +27,8 @@ magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
class LocalStatusFolder(BaseFolder):
def __init__(self, name, repository):
self.sep = '.' #needs to be set before super.__init__()
super(LocalStatusFolder, self).__init__(name, repository)
self.sep = '.'
self.filename = os.path.join(self.getroot(), self.getfolderbasename())
self.messagelist = {}
self.savelock = threading.Lock()

View File

@ -60,10 +60,10 @@ def gettimeseq():
class MaildirFolder(BaseFolder):
def __init__(self, root, name, sep, repository):
self.sep = sep # needs to be set before super().__init__
super(MaildirFolder, self).__init__(name, repository)
self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
self.root = root
self.sep = sep
self.messagelist = None
# check if we should use a different infosep to support Win file systems
self.wincompatible = self.config.getdefaultboolean(

View File

@ -324,6 +324,8 @@ class IMAPRepository(BaseRepository):
:param foldername: Full path of the folder to be created."""
if self.getreference():
foldername = self.getreference() + self.getsep() + foldername
if not foldername: # Create top level folder as folder separator
foldername = self.getsep()
imapobj = self.imapserver.acquireconnection()
try: