[POLL] unexpunge behavior

Ken Murchison ken at oceana.com
Tue May 3 10:57:13 EDT 2005

As most of you probably know (or at least *should* know), removing a 
message from an IMAP mailstore is a two-step process.  First the message 
has its \Deleted flag set with the STORE command, then any messages with 
this flag are expunged using either the EXPUNGE or CLOSE command.  IMAP 
itself has no concept of a Trash folder.  The Trash folder concept is 
something that is layered (some say hacked) on top of the delete+expunge 

Since the most expensive part of the expunge process is actually 
unlink()ing the message files and rebuilding the cyrus.cache file, in 
the 2.3 branch of Cyrus we have implemented something we call "delayed 
expunge".  With delayed expunge, the cyrus.index records of the expunged 
messages are moved to a cyrus.expunge file, but the message files and 
cyrus.cache records remain.  This has the effect of removing the 
messages from the server (no message "exists" without a cyrus.index 
record), without all of the expensive overhead so the client gets more 
responsive behavior.  The actual completion of the expunge is handled 
with the cyr_expire utility which is run periodically to unlink() the 
message files and rewrite the cyrus.cache file.

In addition to providing better performance for client, the fact that 
the message file and corresponding cache record are left behind provides 
a window of opportunity for an admin to go back and unexpunge messages 
if need be.  To this end, I have written an unexpunge utility which 
simply restores the cyrus.index record of the expunged message to its 
original content.  Keeping in mind that removing a message is a two-step 
process, the unexpunge utility (by default) only undoes the second step 
and reverts the message back to its "deleted but not yet expunged" 
state.  This means that the \Deleted flag is still set, and depending 
upon the IMAP client configuration, may appear with an "X" icon, 
strikethrough text, or be hidden entirely.  To help such clients, I have 
also implemented a -d option for the unexpunge utility which unsets the 
\Deleted flag when restoring the message.

So, my question is, what should the *default* behavior of unexpunge be:

A. only unexpunge the message and leave the \Deleted flag set as-is 
(only undo the expunge step)?

B. unexpunge the message and unset the \Deleted flag (undo both the 
expunge and delete steps)?

I'm of the opinion that A is the correct default behavior and admins can 
use the -d option as they see fit, but I will make the default behavior 
whatever the consensus ends up being.

Kenneth Murchison     Oceana Matrix Ltd.
Software Engineer     21 Princeton Place
716-662-8973 x26      Orchard Park, NY 14127
--PGP Public Key--    http://www.oceana.com/~ken/ksm.pgp
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

More information about the Info-cyrus mailing list