[PATCH] Syncing gmail labels for gmail accounts
Abdó Roig-Maranges
abdo.roig at gmail.com
Sat Nov 24 12:45:55 GMT 2012
Hi Dima,
> I noticed some unexpected behaviour regarding message deletion. If I
> delete messages in ~/Maildir/[Google Mail]/All Mail using mutt, and
> re-sync the local store using offlineimap, the messages don't get
> deleted.
This is not related to the labels patch. Gmail's IMAP is weird. And this
is an example of that.
As far as I understand, deleting a message from any folder is reflected
on the gmail side by removing the corresponding label... except for the
special "All Mail" folder. Physically deleting a message from the local
"All Mail" has no effect, the message just reappears on the next
sync. This is gmail's weirdness, not offlineimap's.
To delete messages locally, you should move it to the trash folder. When
a message goes to trash, gmail removes all other labels, and deletes the
message from "All Mail" [1].
Offlineimap had a realdelete option that moved messages to trash when
deleting them, but it could lead to data loss [2] and is no longer
there. Now, simply move messages to trash manually to remove them,
either by
* syncing the special folder [Google Mail]/Trash, and physically moving
the message there
* or adding the label '\Trash' to the message (The initial '\' is
because it is a special gmail label, like \Draft or \Inbox)
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.
What I have tried is syncing both, "All Mail" and "Trash" using
folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail', '[Gmail]/Trash']
on the remote gmail section of the config file. The problems are:
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.
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.
So, for now, to delete a mesage, either do it from the web interface, or
set the labels of the messages to '\Trash' (remove all the other
labels). I don't know if you can do that from mutt.
Abdó.
[1] http://support.google.com/mail/bin/answer.py?hl=en&answer=77657
[2] http://permalink.gmane.org/gmane.mail.imap.offlineimap.general/5265
More information about the OfflineIMAP-project
mailing list