WIP, revamp how we treat top-level dirs
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
ff50585007
commit
78a37f27ef
@ -37,13 +37,14 @@ class BaseFolder(object):
|
|||||||
self.sync_this = True
|
self.sync_this = True
|
||||||
"""Should this folder be included in syncing?"""
|
"""Should this folder be included in syncing?"""
|
||||||
self.ui = getglobalui()
|
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.repository = repository
|
||||||
self.visiblename = repository.nametrans(name)
|
self.visiblename = repository.nametrans(name)
|
||||||
# In case the visiblename becomes '.' (top-level) we use '' as
|
# In case the visiblename becomes '.' or '/' (top-level) we use
|
||||||
# that is the name that e.g. the Maildir scanning will return
|
# '' as that is the name that e.g. the Maildir scanning will
|
||||||
# for the top-level dir.
|
# return for the top-level dir.
|
||||||
if self.visiblename == '.':
|
if self.visiblename == self.getsep():
|
||||||
self.visiblename = ''
|
self.visiblename = ''
|
||||||
self.config = repository.getconfig()
|
self.config = repository.getconfig()
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ except NameError:
|
|||||||
class IMAPFolder(BaseFolder):
|
class IMAPFolder(BaseFolder):
|
||||||
def __init__(self, imapserver, name, repository):
|
def __init__(self, imapserver, name, repository):
|
||||||
name = imaputil.dequote(name)
|
name = imaputil.dequote(name)
|
||||||
|
self.sep = imapserver.delim
|
||||||
super(IMAPFolder, self).__init__(name, repository)
|
super(IMAPFolder, self).__init__(name, repository)
|
||||||
self.expunge = repository.getexpunge()
|
self.expunge = repository.getexpunge()
|
||||||
self.root = None # imapserver.root
|
self.root = None # imapserver.root
|
||||||
self.sep = imapserver.delim
|
|
||||||
self.imapserver = imapserver
|
self.imapserver = imapserver
|
||||||
self.messagelist = None
|
self.messagelist = None
|
||||||
self.randomgenerator = random.Random()
|
self.randomgenerator = random.Random()
|
||||||
|
@ -27,8 +27,8 @@ magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
|
|||||||
|
|
||||||
class LocalStatusFolder(BaseFolder):
|
class LocalStatusFolder(BaseFolder):
|
||||||
def __init__(self, name, repository):
|
def __init__(self, name, repository):
|
||||||
|
self.sep = '.' #needs to be set before super.__init__()
|
||||||
super(LocalStatusFolder, self).__init__(name, repository)
|
super(LocalStatusFolder, self).__init__(name, repository)
|
||||||
self.sep = '.'
|
|
||||||
self.filename = os.path.join(self.getroot(), self.getfolderbasename())
|
self.filename = os.path.join(self.getroot(), self.getfolderbasename())
|
||||||
self.messagelist = {}
|
self.messagelist = {}
|
||||||
self.savelock = threading.Lock()
|
self.savelock = threading.Lock()
|
||||||
|
@ -60,10 +60,10 @@ def gettimeseq():
|
|||||||
|
|
||||||
class MaildirFolder(BaseFolder):
|
class MaildirFolder(BaseFolder):
|
||||||
def __init__(self, root, name, sep, repository):
|
def __init__(self, root, name, sep, repository):
|
||||||
|
self.sep = sep # needs to be set before super().__init__
|
||||||
super(MaildirFolder, self).__init__(name, repository)
|
super(MaildirFolder, self).__init__(name, repository)
|
||||||
self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
|
self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
|
||||||
self.root = root
|
self.root = root
|
||||||
self.sep = sep
|
|
||||||
self.messagelist = None
|
self.messagelist = None
|
||||||
# check if we should use a different infosep to support Win file systems
|
# check if we should use a different infosep to support Win file systems
|
||||||
self.wincompatible = self.config.getdefaultboolean(
|
self.wincompatible = self.config.getdefaultboolean(
|
||||||
|
@ -324,6 +324,8 @@ class IMAPRepository(BaseRepository):
|
|||||||
:param foldername: Full path of the folder to be created."""
|
:param foldername: Full path of the folder to be created."""
|
||||||
if self.getreference():
|
if self.getreference():
|
||||||
foldername = self.getreference() + self.getsep() + foldername
|
foldername = self.getreference() + self.getsep() + foldername
|
||||||
|
if not foldername: # Create top level folder as folder separator
|
||||||
|
foldername = self.getsep()
|
||||||
|
|
||||||
imapobj = self.imapserver.acquireconnection()
|
imapobj = self.imapserver.acquireconnection()
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user