<<< Date Index >>>     <<< Thread Index >>>

Re: Using a maildir or mh folder for the message cache?



On Tuesday, August  8 at 10:29 AM, quoth Rocco Rutte:
It won't work for a simple reason: the filenames in which messages are stored are named by unique IDs given by the server. This is UIDL for POP and UID for IMAP.

I don't know very much about mh, but at least for maildir an operation like 'flag' or 'reply' could change the filename so that next time, the body cache won't find the message because of the rename.

Nonsense. Maildir messages are indeed renamed, but they're only renamed by appending :2,X to the name, where X is a set of one-character flags (S for seen, F for flagged, R for replied, etc.). Maildir messages are NOT to be renamed in any more drastic way for the simple fact that you supposedly went to a great deal of trouble to pick a good (nonconflicting) name in the first place. From the maildir specification (http://cr.yp.to/proto/maildir.html):

When you move a file from new to cur, you have to change its name from "uniq" to "uniq:info". MAKE SURE TO PRESERVE THE "uniq" STRING, so that separate messages can't bump into each other.

(emphasis mine) Thus, you can extract the original filename with this simple code:

   char * tail = strrchr(filename, ':');
   if (tail) *tail = 0;
   printf("IMAP UID is %s\n", filename);

Tada!

But: if one understands that very clearly, it's trivial to set up symlinks to use either a POP or IMAP body cache as a read-only maildir folder. This works nicely.

Perhaps a script to do so would be a nice thing to add to the docs?

~Kyle
--
There in America we are descended in blood and in spirit from revolutionist and rebel men and women who dare to dissent from accepted doctrine. As their heirs, may we never confuse honest dissent with disloyal subversion.
                                              -- Dwight D. Eisenhower

Attachment: pgpqYRcYhhcrF.pgp
Description: PGP signature