Gmail Label Sync - Label Header Duplication Issue

Ethan Schoonover es at ethanschoonover.com
Wed Nov 19 19:55:36 GMT 2014


I have been using the new gmail sync feature along with Gaute Hope's
great keywsync (abunchoftags) utility to round-trip notmuch tags to
gmail labels. All works well, except for a reproducible situation that
I will outline below. This appears to be irrespective of Gaute's
utility or any other part of my email processing. I have tested this
with a "clean room" offlineimap-only install, not using any other
utilities, so I'm fairly certain it is an offlineimap only issue.


SUMMARY:
Offlineimap may create multiple headers recording the gmail labels
when a message is refiled remotely on the gmail server. The last of
these is always the correct header, but upon any subsequent scan of
the message due to mtime change, offlineimap will read in only the
first header, resulting in an incorrect relabeling of the message.

Thus the issue is that, in a multiple-label-header condition,
offlineimap writes to a new header at the end of the header sequence,
but subsequently reads from the first label-header available.


WHAT SHOULD HAPPEN?
Offlineimap should either NOT create multiple label headers or should
consistently read write to the same (either first or last) label
header.



REPRODUCIBLE EXAMPLE:
The state of the headers (X-Keywords in this case) is shown in each step below:



FIRST SYNC - REMOTE TO LOCAL WITH LABEL SYNC
(fresh from Gmail to local maildir, all repository types set
to gmail specific type values)
----------------------------------------------------------
...
X-Keywords: \Inbox
...



SECOND SYNC - LOCAL LABEL MODIFICATION
Local modification test (adding a label using vim in this case)
SUCCESSFULLY adds message to the "testlabel" label in gmail
----------------------------------------------------------
...
X-Keywords: \Inbox,testlabel
...



THIRD SYNC - REMOTE LABEL ADDITION
Add another label to the same message remotely on gmail.
This results in a second X-Keywords header.
----------------------------------------------------------
...
X-Keywords: \Inbox,testlabel
X-Keywords: \Inbox,testlabel,newlabel
...



FOURTH SYNC - POST LOCAL MTIME ONLY CHANGE
touch the file locally (or edit/save) in the maildir to change
modification time and sync again...
offlineimap now reads ONLY the first of the headers it created and
removes the label
we just added.
----------------------------------------------------------
...
X-Keywords: \Inbox,testlabel
...



-Ethan Schoonover




More information about the OfflineIMAP-project mailing list