[PATCH] Folder: Force top-level folder visiblename to ''

Sebastian Spaeth Sebastian at SSpaeth.de
Fri Sep 23 13:36:49 BST 2011


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 at SSpaeth.de>
---
This patch is now in my next branch. Let me know if it fixes the problem.

 offlineimap/folder/Base.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index d9fed70..909db30 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -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):
-- 
1.7.4.1





More information about the OfflineIMAP-project mailing list