Skip to content

Commit

Permalink
Avoid trying to synchronize folders that have empty names
Browse files Browse the repository at this point in the history
Hello,

I am hitting the same issue as Jes Sorensen[1], where at some point,
offlineimap 6.5.4 would error out with the message:

 Establishing connection to mail.corp.foo.com:993
 Creating new IMAP folder '/' on server RemoteFoo
 ERROR: Creating folder  on repository RemoteFoo
  Folder '/'[RemoteFoo] could not be created. Server responded:
('NO', ['CREATE failed: invalid mailbox name'])
 ERROR: Folder '/'[RemoteFoo] could not be created. Server responded:
('NO', ['CREATE failed: invalid mailbox name'])
 *** Finished account 'Foo' in 0:03

I chased it down and it looks like the issue happens when we have a
local Maildir format, subfolders and where the separator is '/'.

Since commit a279aa7 [2], it can happen that offlineimap wrongly tries
to create a folder named '/' on the remote server.

I believe the problem is that MaildirRepository._getfolders_scandir
which is supposed to scan the list of IMAP folders under a given root
folder can now return a folder that has an empty path.  A consumer of
that function then appends the IMAP folder path separator to that empty
folder name, and tries to create the resulting folder name '/' on the
server.  Oops.

The patch accompanying this message addresses the issue by ensuring that
that function never yields an empty path.

Though, in the grand scheme of things, I don't understand why the change
in [2] would be the right fix to begin with. Is that function the right
place to make nametrans related decisions?  It seems to like that
function ought to returns what it really sees on the physical Maildir
directory.

[1]: http://article.gmane.org/gmane.mail.imap.offlineimap.general/5696

[2]: commit a279aa7
     Author: Sebastian Spaeth <Sebastian@SSpaeth.de>
     Date:   Mon Sep 19 14:14:44 2011 +0200

        Maildir: Call top-level directory '', not '.'

        If nametrans translates to an empty directory we want to find the
        top-level directory by name '' and not by name '.'. This unbreaks
        nametrans rules that result in empty folder names.

        Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>

And now the patch.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
  • Loading branch information
Dodji Seketeli authored and nicolas33 committed Aug 24, 2012
1 parent 6e5fbeb commit 35bccdc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions offlineimap/repository/Maildir.py
Expand Up @@ -152,8 +152,15 @@ def _getfolders_scandir(self, root, extension = None):
# Iterate over directories in top & top itself.
for dirname in os.listdir(toppath) + ['']:
self.debug(" dirname = %s" % dirname)
if dirname == '' and extension is not None:
self.debug(' skip this entry (already scanned)')
if dirname == '':
if extension is not None:
# We are skipping this because it has already be
# scanned
self.debug(' skip this entry (already scanned)')
else:
# We are skipping this because a directory with an
# empty path name does not make sense
self.debug(' skip this entry (None)')
continue
if dirname in ['cur', 'new', 'tmp']:
self.debug(" skip this entry (Maildir special)")
Expand Down

0 comments on commit 35bccdc

Please sign in to comment.