IMAP server upgrades

(That's my neighbor's car. Envy, envy.)
I'm posting this entry primarily because a) I felt like a slacker for not posting much at all lately, and b) so that I might wedge this bit of info into Google for some other poor bastard.
I've been using UW-IMAP for years. Not because it's a good piece of software -- all software that has come out of the UW is just a little bit...off. I say this with much affection, but having to use UWIN and Pine while at school there led me to believe that any officially-sponsored software had to have some fatal flaw and violate either standards or conventions.
In fact, I'd just like to point out that it took the UW until 1999 to abandon UWIN and convert to the Web.
Anyway, I've been using UW-IMAP, because it compiles more or less easily (with a few manual steps and no Makefile, natch), and I've used it for a few years. It sticks to itself more or less, and while bloody slow, my personal email system is brittle enough that it's easier not to mess with things.
However, Mail.app + UW-IMAP != TLA. It's slow. Synchronising a single mailbox took ages, and I had to archive off mboxes just to keep it from taking twenty seconds every time I opened a mailbox.
In addition, I used IMAP clients from multiple places, including Chatter EMail on my Treo. Two MUAs accessing the same mailbox is a big no-no with mbox file locking. I wanted to move back to Maildir, which I had used up until 1999 or so.
I poked around, looking at different IMAP servers, and stumbled upon dovecot. I downloaded it, built and installed it, and pointed it at my mbox hierarchy. After disabling UW-IMAP in xinetd.d, I kicked it over and restarted Mail.app.
All of this took about five minutes. It worked, and due to dovecot's server-side index, it was fast.
I shut it back down for a bit and used mb2md.pl to convert my mboxes to Maildir. I've happily said goodbye to those stupid DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA messages and IMAP folder prefixes.
So, here's the kinda icky bit. After doing this, I discovered that some of my folders seemed a little...confused, on the Mac. I'd view a message listing copied over from mbox, click on a message, and see a completely different message in the preview pane. Wtf? I thought perhaps it was on the server side, but mutt behaved quite happily.
"Eww, cache," was the horrible thought floating through my head at this point. I've been using computers long enough to know that, while it's often quite easy to delete something that looks like "cache" or "store" or "index", it's also quite easy to learn that "cache" or "store" or "index" might be a buttress holding up a wall, or a load-bearing card in that house you just built, or some other architectural metaphor of the "here be dragons" sort.
I've been bitten by my own cleverness enough that I've been bitten by second-order cleverness. I've imperiled myself several times by trying to avoid the important-buttress-deletion problem. Thanks to Apple and iTunes, I'm not averting disaster by mv'ing the file or directory I'd like to delete. In a perfect world with no side effects, I'd mv a file, start the app up, and if it complained, I'd shut it back down, mv the file back, and all would be forgiven. Never mind the other files into which Apple applications squirrel away data, and are rebuilt or corrupted if some other file disappears.
Soo...it is with some trepidation that I trod into /Library/Mail. I first tried deleting all the messages in IMAP-{username}@{mailserver}, because that looked safest and most obvious. No dice. Then I saw /Library/Mail/Envelope Index. more didn't help me out, but strings did, and it looked like a SQLite database with message information. Carefully mv'ing the file and restarting Mail.app just about caused me to poo my pants when it popped up a splash screen.
"Import Mailboxes"
"fux0r! It's going to look for stuff I don't have, I'll have to recreate all my settings, it'll take all night -- oh, it's mail, who cares?"
It all ended up ok, and importing my active mailboxes (only about 10k messages because I had to be so aggresive in archiving large mboxes with UW-IMAP) in about five minutes.
So, for anyone looking for "mail.app cache" or "mail.app imap message store" or whatever, I hope this helps.