On 2013-12-12 12:47, Roland Rosenfeld wrote:
Hi!

Usually dovecot auto detects or repairs the size of a maildir
message.  So I can place a message named "foo" in the cur directory
and dovecot uses it.

Now I tried the same with a zlib compressed message but here dovecot
doesn't recognize/repair the size of the message.

When I access this folder via IMAP the connection is diconnected and
in dovecot logs I see the following error messages:

[..]

Error: Cached message size smaller than expected (805 < 2666)
Error: Maildir filename has wrong S value, renamed the file from
/somedir/cur/1386772057.M152553P9709.host,S=805:2, to
/somedir/cur/1386772057.M152553P9709.host,S=805:2,

So here dovecot detects the wrong S value, but instead of fixing it by
using the uncompressed size, it renames to the same file name as
before...

I observed exactly the same issue ever since I enabled the zlib
plugin on our IMAP server, running dovecot 2.1.7.

For what it's worth, I wrote a small shell script which, given a
Maildir directory, looks for all files for which the S= value doesn't
match the effective file size (i.e. for zlib-compressed files,
the S= value should match the *uncompressed* file size, for
plain files the S= value should match the physical file sie). The
script the attempts to print appropriate 'mv' commands for renaming
the files as needed. Maybe it helps, I attached it to this mail.


--
Frerich Raabe - ra...@froglogic.com
www.froglogic.com - Multi-Platform GUI Testing
#!/bin/sh

files=`find "$1" -type f`

for f in $files; do
    actual_size=`ls -l "$f" | awk '{print $5}'`
    expected_size=`echo $f | sed -e 's,.*S=\([0-9]\+\).*,\1,'`
    if file "$f" | grep gzip > /dev/null; then
        if test $actual_size -eq $expected_size; then
            real_size=`zcat "$f" | wc -c`
            # echo "$f (gzipped): expected $expected_size, actual $actual_size, 
real $real_size"
            real_filename=`echo $f | sed -e 
"s,\(.*\)S=[0-9]\+\(.*\),\1S=$real_size\2,"`
            echo "mv \"$f\" \"$real_filename\""
        fi
    else
        if test $actual_size -ne $expected_size; then
            # echo "$f (raw): expected $expected_size, actual $actual_size"
            real_filename=`echo $f | sed -e 
"s,\(.*\)S=[0-9]\+\(.*\),\1S=$actual_size\2,"`
            echo "mv \"$f\" \"$real_filename\""
        fi
    fi
done

Reply via email to