spaetz/offlineimap — Issue #14: Gmail "realdelete" can cause potentially DATALOSS
Author: spaetz
Created: 2012-01-08 00:15:48+00:00
State: open
Labels: Bug, Dataloss!

WARNING: I consider the Gmail "realdelete" option as harmful with the
potential for DATALOSS. Add scary warnings to offlineimap.conf.

See the analysis at
http://article.gmane.org/gmane.mail.imap.offlineimap.general/5265
Deleting a message from a Gmail folder via the IMAP interface will just
remove that folder's label from the message: the message will continue
to exist in the '[Gmail]/All Mail' folder. If `realdelete` is set to
`True`, then deleted messages will be moved to the '[Gmail]/Trash'
folder. BEWARE: this will immediately delete a messages from *all
folders* it belongs to!

AS OFFLINEIMAP IMPLEMENTS FOLDER MOVES AS 1) AN ADD and 2) A DELETE (the
order can vary), THIS MEANS THAT A FOLDER MOVE CAN CAUSE DATALOSS. DO
NOT USE IT AND MOVE MAIL TO "[Gmail]/Trash" TO DELETE MAIL FROM
"[Gmail]/All Mail"!

We will need to discuss whether to completely disable that feature.

-----------------------------------------------------------------------------------------------

Detailed analysis from the mail here:

A folder move is internally implemented as a) delete from FOLD1 b) add
to FOLD2. The order in which 1 or 2 happens could differ depending on
the order in which we sync our folders.

*IF* you have the option "realdelete=True" set (which I suspect you
have). Then operation "a)" will move the msg from FOLD1 to TRASH which
will internally cause it to lose all tags, ie it *disappears* from all
folders. (Even the "All Mail" thing)

Then, in operation "b)" you upload the MSG2 to FOLD2. This will cause the
msg at the GMail side to 1) Dissappear from TRASH 2) appear in FOLD2 and
3) appear in INBOX (as it is a new msg for Gmail).

It is even worse if we first happen to sync FOLD2 and then FOLD1, in
this case, "b)" will add the folder to Gmail's FOLD2 and "a)" will
move it to FOLD1, which will cause it to disappear from ALL folders
(including FOLD2 that we just added the msg to). In effect it ends up
only in Trash. This is outright data loss...

This is just the weird way Gmail folders behave, combined with the
"realdelete" option, which causes this behavior. I don't see *any* way
we can work around that without turning "realdelete" off. I will add a
note to the docs about its dangerous behaviour.

If you set "realdelete=False" (or delete it), does it still behave this
way? It should work just fine then, it should just keep all mails in "All
Mails" (unless they are moved to Gmail's Trash folder.

I don't think we can do a lot, except telling people to a) not use
realdelete (disable it as I cannot see its positive use) and b) to
always move files into the Gmail/Trash folder if they want to have a
mail really disappear from their "All Mail" box.