[PATCH] Syncing gmail labels for gmail accounts

Abdó Roig-Maranges abdo.roig at gmail.com
Sat Nov 24 14:13:45 GMT 2012

Hi again,

> Regarding the labels patch... well, I haven't done much email
> trashing recently, so I didn't notice earlier. I found a couple of
> problems with labels sync for the Trash folder. I'll look into
> it and post again.
>   1) Moving a message to trash keeps the old labels (\Inbox for example)
>      because of the label sync. Gmail should clear all labels, but we
>      resync them back afterwards. I'm not sure what's the best way to
>      fix this.

After thinking about it, I believe there is no problem to fix. As a side
effect of labels sync, the Trash folder behaves like all other folders
regarding labels, instead of being special and clearing all
labels. That's fine to me.

Then if I, as a user, want to trash a message and not see it on the
Inbox (or whatever other folder it belongs), I should explicitly remove
the \Inbox label.

If I wanted to keep the special behaviour of Trash regarding labels,
Offlineimap should be aware that Trash is special and prevent labels
sync, and this would be a little ugly, I guess. For instance, the trash
folder name depends on the localization: [Gmail]/Trash,
[Gmail]/Papelera, [Google Mail]/Bin, etc...

>   2) A python KeyError for Gmail.messagelabels[uid]['labels'], which
>      seems to be triggered by the fact that the messages in the Trash
>      folder behave differently when setting labels.

Well, that was a bug in my patch. It was triggered only when a new
message with labels moved from local to gmail, for example when moving
between folders "the IMAP way". I attach a patch. you can also pull it
from github: https://github.com/aroig/offlineimap

Thanks for the feedback :)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: uidfix.patch
Type: text/x-patch
Size: 1602 bytes
Desc: patch
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20121124/09bb4534/attachment-0003.bin>

More information about the OfflineIMAP-project mailing list