Prevent deletion of messages during sync per-folder?

Sebastian Spaeth Sebastian at
Sun May 1 18:52:44 BST 2011

On Thu, 28 Apr 2011 11:54:27 -0600, Will Styler wrote:

> My apologies for a rather user-directed question, but I'm so far unable to find a way that I can ask offlineIMAP to decline to delete local copies of a message from certain folders, for instance, "Trash".  My IMAP provider (MobileMe) has recently started clearing messages older than 30 days from the server, and I'd like the local trash folder to keep a long-term archive for referencing elsewhere.  

Fun. And not trivial, as I see it it's not possible today :-).

What is possible now:
1) Mark a full repository read-only, thus enabling 1-way syncing. This
   is not what you want or need, and it's for a full repo only.

2) put "Trash" in folderexcludes, it will then not sync "Trash" at all,
   but it will keep those in your local "Trash" that are already there. New
   ones wouldn't be put in there though.

(actually this is all I can come up with for now, the "maxage" option
that I though of first wouldn't be of use here).

So what you want is essentially a DONT_DELETE_FOLDER_LIST =
['Trash','INBOX.Otherfolder'] ?

This has been ocasionally been requested for the full repo, but I have
been very reluctant on it, because as you say, moving between folders
etc would lead to duplicate messages. But for specific folders I can see
how it could be useful in certain cases.

> However, I'm aware that this could be difficult to implement, as OfflineIMAP would then want to sync all those messages which it has kept and the server hasn't back up to the server during the next sync (unless they were marked somehow as "local-only".  So, as a secondary (and perhaps easier) option, is there a way to create a local folder which mirrors the trash folder (but has no deletion) and is not synced back to the server?

There are 2 complications. The first one is that we (unfortunately) use
the local "deletemessage()" function in order to record a new UID by
first savemessage() a mail with a new UID and then deletemessage() it
with the old UID. But that is a silly behavior (inolving lots of
uneccessary copying) anyway and should be fixed. (the deletemessage()
part wouldn't work in this case).

The second one is as you outline: we detect that the server has deleted
a message and will try to delete it on the local side too (and from our
status cache). We would need to prevent that behavior. As for preventing
uploading from LOCAL to REMOTE, we would not try to attempt this as long
as we still have the LocalStatus cache entry for the mail when we
downloaded it, so I don't think implementing this behavior is very difficult.
> Thanks, and I apologize if this is a silly question or isn't the forum for it,

IMHO not silly at all.
I have made a note on my private issue tracker:

Our current TODO list is pretty long, but I have this on my radar now.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <>

More information about the OfflineIMAP-project mailing list