From 78a37f27ef26f754eec56ae91cdaa3fc114a145c Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 30 Sep 2011 17:20:11 +0200 Subject: [PATCH] WIP, revamp how we treat top-level dirs Signed-off-by: Sebastian Spaeth --- offlineimap/folder/Base.py | 11 ++++++----- offlineimap/folder/IMAP.py | 2 +- offlineimap/folder/LocalStatus.py | 2 +- offlineimap/folder/Maildir.py | 2 +- offlineimap/repository/IMAP.py | 2 ++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 0e065e3..313728d 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -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() diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 5d8d1c0..d804766 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -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() diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py index fd4228c..3d2cd37 100644 --- a/offlineimap/folder/LocalStatus.py +++ b/offlineimap/folder/LocalStatus.py @@ -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() diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index d7639f4..973bc92 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -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( diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 8635f7c..a5ed84c 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -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: