Folder names with spaces result in an Assertion error
When syncing between two Dovecot servers, of which the first has a folder with a name containing a space and the second has no content, something like the following happens:
Syncing b'Deleted items' into b'Deleted items'
Traceback (most recent call last):
File "imapcp.py", line 244, in <module>
app.run()
File "imapcp.py", line 171, in run
assert res == 'OK', (res, data)
AssertionError: ('NO', [b"Mailbox doesn't exist: Deleted"])
Apparently, it needs to be surrounded by quotes (thanks to Max).
Changing line 142 and 143 from...
srcfolder = f.name
dstfolder = f.getPathBytes(dsttype, trim=options.trim)
...to the following solves the problem (of course this isn’t the prettiest code like, though).
srcfolder = '"{}"'.format(f.name.decode("utf-8"))
dstfolder = '"{}"'.format(f.getPathBytes(dsttype, trim=options.trim).decode("utf-8"))
That's what I was just writing: dovecot usually likes quoting, so adding that as a quick fix will work.
Anyway, to support different IMAP servers, some additional if/then login will be needed.
Nice haha, but then I guess a PR with these changes wouldn’t really help, right?
If you can add some if to apply that only when the mailserver is dovecot, I will happily merge it
Ooh, right. I’ll look into that! Just found out this breaks the exclude option though, since match doesn’t like it.
Traceback (most recent call last):
File "imapcp.py", line 243, in <module>
app.run()
File "imapcp.py", line 153, in run
if e.match(srcfolder):
TypeError: can't use a bytes pattern on a string-like object

That fix also solves the above error