[Dovecot] Fixing bad maildir message sizes

Richard Platel rplatel at tucows.com
Wed Jan 23 00:19:31 EET 2013

Thanks Timo.

I was writing out corrupted dovecot-uidlist files, fixing that solved the issue.

Attached is a script that fixes message names.  It's not fully QA'ed yet, and uses some of our site-specific stuff to figure out who owns the maildir and to boot the user while making changes, but might be useful as a starting point.  Note that it handles compressed and uncompressed messages.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: MaildirSizeFix.pm
Type: text/x-perl-script
Size: 6790 bytes
Desc: not available
URL: <http://dovecot.org/pipermail/dovecot/attachments/20130122/901d1d97/attachment-0004.bin>
-------------- next part --------------

On 2013-01-22, at 7:01 AM, Timo Sirainen <tss at iki.fi> wrote:

> 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