OfflineIMAP / offlineimap

Read/sync your IMAP mailboxes (python2) [LEGACY: move to offlineimap3]
http://www.offlineimap.org
Other
1.78k stars 360 forks source link

Error while syncing emails in a folder, results in duplicates on the server #676

Closed mpsq closed 4 years ago

mpsq commented 4 years ago

I moved 2 emails into a folder Pers with mu4e on my mailfence account, since then, I get an error on sync and this results in messages being duplicated on the server (I noticed the problem when it reached 100 dupes).

General information

Configuration file offlineimaprc

[general]
accounts = mailfence,...
maxsyncaccounts = 1
pythonfile = ~/.offlineimap.py

[Account mailfence]
localrepository = mailfence-local
remoterepository = mailfence-remote

[Repository mailfence-local]
type = Maildir
localfolders = ~/.mail-archive/mailfence

[Repository mailfence-remote]
type = IMAP
remotehost = imap.mailfence.com
remoteuser = #######@mailfence.com
remotepasseval = from_gpg("mailfence")
ssl = yes
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

Logs, error

 Pers: could not determine the UID while we got no error while appending the email with 'X-OfflineIMAP: 123743001-7429849006'
 ERROR: While attempting to find UID for message with header X-OfflineIMAP, got wrong-sized matchinguids of ['1016', '1016']
 Copy message UID -1 (2/2) mailfence-local:Pers -> mailfence-remote:Pers
Folder Trash [acc: mailfence]:
 Syncing Trash: IMAP -> Maildir
Folder Pers [acc: mailfence]:
 Pers: could not determine the UID while we got no error while appending the email with 'X-OfflineIMAP: 3141711139-6507093985'
 ERROR: While attempting to find UID for message with header X-OfflineIMAP, got wrong-sized matchinguids of ['1017', '1017']
Account sync mailfence:
 *** Finished account 'mailfence' in 0:03
ERROR: Exceptions occurred during the run!
ERROR: While attempting to find UID for message with header X-OfflineIMAP, got wrong-sized matchinguids of ['1016', '1016']

Traceback:
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 844, in copymessageto
    new_uid = dstfolder.savemessage(uid, message, flags, rtime)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 737, in savemessage
    headervalue)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 412, in __savemessage_searchforheader
    OfflineImapError.ERROR.MESSAGE

ERROR: While attempting to find UID for message with header X-OfflineIMAP, got wrong-sized matchinguids of ['1017', '1017']

Traceback:
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/Base.py", line 844, in copymessageto
    new_uid = dstfolder.savemessage(uid, message, flags, rtime)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 737, in savemessage
    headervalue)
  File "/usr/lib/python2.7/site-packages/offlineimap/folder/IMAP.py", line 412, in __savemessage_searchforheader
    OfflineImapError.ERROR.MESSAGE

Steps to reproduce the error

Thank you for your help :)

nicolas33 commented 4 years ago

The IMAP server doesn't support the UIDPLUS extension so offlineimap fallbacks on the internal legacy way of mapping the UID to the uploaded message. The server responds with 2 UIDs so offlineimap doesn't know which one is correct and reports this error.

For some reason both UIDs are equals so it's very likely fine to map either one. I've written a fix above. Please, try this patch.

nicolas33 commented 4 years ago

I wonder you might find issues on the next run. Please, backup the cache and the maildirs before applying.

mpsq commented 4 years ago

Thanks Nicolas for your quick answer.

I tried the branch and it works perfectly! No more errors or duplicated messages, everything is good now :)

Thank you very much for that fix :tada:

nicolas33 commented 4 years ago

Thanks for your report. I've merged the patch so it should be in the next release.