[Dovecot] Fixing bad maildir message sizes

Timo Sirainen tss at iki.fi
Tue Jan 22 14:01:51 EET 2013


On 21.1.2013, at 21.54, Richard Platel <rplatel at tucows.com> wrote:

> As stated in my previous message, we have some old compressed maildir messages with incorrect sizes in the filename.  These messages cause dovecot 2.x problems.
> 
> I'm trying to write a script to crawl all our messages, check the actual message size and if necessary, fix the filename.  However, when I do this, dovecot gives the message a new UID on next login.  If I change the filename in dovecot-uidlist, dovecot still gives a new UID on next login.  If I change dovecot-uidlist and delete the index, then the UID is preserved.

I don't really understand why deleting dovecot.index* would make a difference here, except maybe as a workaround in case the user has that mailbox selected, because the filenames could be cached in memory.

http://dovecot.org/tools/maildir-size-fix.pl
http://dovecot.org/tools/maildir-size-check.sh

Those scripts kind of do what you want, except not fully, so it would be nice to get one fully finished one :) The best way for the script to would would be to:

 * scan through a maildir, figure out what needs to be renamed to what, but don't actually do it
 * lock the maildir with dovecot-uidlist.lock (src/util/maildirlock comes with dovecot)
 * doveadm kick user's imap/pop3 sessions, and even better if it was possible to kill -9 any pending processes
 * rename the files and update dovecot-uidlist
 * delete dovecot-uidlist.lock

This separately for each folder.



More information about the dovecot mailing list