Do not ignore gmail labels if header appears multiple times

There should be just one header storing gmail labels, but due to a bug,
multiple X-Keywords (or equivalent) headers may be found on the local
messages.

Now we, when extracting the labels from a message, we read all label
headers, instead of just the first one.

This has the consequence that some old labels stored locally in a second
X-Keywords (or third...) header, which effectively was rendered
invisible to offlineimap until now, may pop back up again and be pushed
to gmail. No labels will be removed by the changes in this commit,
though.

Signed-off-by: Abdo Roig-Maranges <abdo.roig@gmail.com>
This commit is contained in:
Abdo Roig-Maranges
2014-11-20 14:03:15 +01:00
parent e51ed80ecc
commit fc4c7549d6
3 changed files with 37 additions and 12 deletions

View File

@ -189,8 +189,9 @@ class GmailFolder(IMAPFolder):
if not self.synclabels:
return super(GmailFolder, self).savemessage(uid, content, flags, rtime)
labels = imaputil.labels_from_header(self.labelsheader,
self.getmessageheader(content, self.labelsheader))
labels = set()
for hstr in self.getmessageheaderlist(content, self.labelsheader):
labels.update(imaputil.labels_from_header(self.labelsheader, hstr))
ret = super(GmailFolder, self).savemessage(uid, content, flags, rtime)
self.savemessagelabels(ret, labels)