Fix recursively scanning Maildir folders

Commit 1754bf4110da251f4aa1dc0803889899b02bfcff introduced a blunder:

-        for dirname in os.listdir(toppath) + ['.']:
+        for dirname in os.listdir(toppath) + [toppath]:
...
-            if self.getsep() == '/' and dirname != '.':
+            if self.getsep() == '/' and dirname:

This change was plainly wrong and would never have worked, so this
commit reverts above bit. While touching the function, some minor code
documentation, cleanup and limiting line length to 80 chars.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Merge branch 'next'
Merge commit 'v6.3.4-rc4'
Merge branch 'next'
Merge branch 'next'
Merge branch 'next'
Merge branch 'next'
Fix string formatting when port is not given.

If port is None, we would try to format an empty string with %d wich
fails. Fix it by using %s.

Reported-by: Iain Dalton <iain.dalton@gmail.com>
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix mbox.select(foldername) readonly parameter comparison

The default parameter value was "None", and we were comparing that
directly to the imaplib2 value of is_readonly which is False or True, so
the comparison always returned "False".

Fix this by setting the default parameter to "False" and not
"None". Also convert all users of that function to use False/True.

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

Conflicts:

	Changelog.draft.rst
Make releaseconnection a NOOP when conn is None

During cleanup we often call releaseconnection in a finally: block. But
in cases of error, we might have dropped the connection earlier already
and set it to "None". In this case don't fail releaseconnection() but
make it a NOOP.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Drop connection if it might be bad on APPEND

1) Differentiate error messages between imaplib.abort and imaplib.error
exceptions in the log.

2) Drop connections in the case of imapobj.error, it also might denote a
   broken connection.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Release current master as 6.4.1

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Fix version number typo in Changelog

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Sanity check to notify us when we call IMAPRepository.getsep() too early

The folder delimiter is only initialized after a call to
acquireconnection(), so we must never call this function too
early. Include an assert() to make sure we get notified when we do.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Remove unused imapserver getdelim()

imapserver.getdelim() was not used at all, so remove this function. The
folder delimiter is available via the repository.getsep() call.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Init folder list early enough

We need the list of folders and the folder delimiter, but it was not
always retrieved early enough. E.g. when doing IMAP<->IMAP sync and the
local IMAP being readonly, we would bunk out with a mysterious error
message become repository.getsel() would still return None.

This commit fixes this error.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Don't append trailing slash to maildir foldernames

When sep='/' in a Maildir, we were doing a os.path.join(dirname,'') on
the top level maildir, which results in a "dirname/", so all our maildir
folder names had slashes appended. Which is pretty much wrong, so this
fixes it by only using os.path.join when we actually have something to
append.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Don't append trailing slash to maildir foldernames

When sep='/' in a Maildir, we were doing a os.path.join(dirname,'') on
the top level maildir, which results in a "dirname/", so all our maildir
folder names had slashes appended. Which is pretty much wrong, so this
fixes it by only using os.path.join when we actually have something to
append.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Add changelog entry for bug fixed in previous commit

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

This is a bugfix release over 6.4.1. Upgrading is recommended.

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