Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder names with spaces result in an Assertion error #1

Open
FMJansen opened this issue Jan 4, 2018 · 6 comments
Open

Folder names with spaces result in an Assertion error #1

FMJansen opened this issue Jan 4, 2018 · 6 comments

Comments

@FMJansen
Copy link

FMJansen commented Jan 4, 2018

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"])
@FMJansen
Copy link
Author

FMJansen commented Jan 4, 2018

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"))

@gtozzi
Copy link
Owner

gtozzi commented Jan 4, 2018

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.

@FMJansen
Copy link
Author

FMJansen commented Jan 4, 2018

Nice haha, but then I guess a PR with these changes wouldn’t really help, right?

@gtozzi
Copy link
Owner

gtozzi commented Jan 4, 2018

If you can add some if to apply that only when the mailserver is dovecot, I will happily merge it

@FMJansen
Copy link
Author

FMJansen commented Jan 4, 2018

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

@mbithy
Copy link

mbithy commented Aug 6, 2018

ANOTHER

That fix also solves the above error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants