Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7016:ac32dc7ae0c1 HEAD
mail_get_physical_size() returns now the message stream's size and not the
physical size on disk that varies. This fixes mbox issues and it's also more
correct conceptually, because it doesn't return metadata size with other
formats either.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 21 Dec 2007 22:58:11 +0200 |
parents | 03cb4c0802a7 |
children | 80d3b8fcec09 |
files | src/lib-storage/index/index-mail.c src/lib-storage/index/mbox/mbox-mail.c src/lib-storage/mail-storage.h |
diffstat | 3 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail.c Fri Dec 21 21:39:58 2007 +0200 +++ b/src/lib-storage/index/index-mail.c Fri Dec 21 22:58:11 2007 +0200 @@ -334,6 +334,9 @@ if (!data->hdr_size_set) return; + /* we've already called get_cached_msgpart_sizes() and it didn't work. + try to do this by using cached virtual size and a quick physical + size lookup. */ if (!index_mail_get_cached_virtual_size(mail, &tmp)) return;
--- a/src/lib-storage/index/mbox/mbox-mail.c Fri Dec 21 21:39:58 2007 +0200 +++ b/src/lib-storage/index/mbox/mbox-mail.c Fri Dec 21 22:58:11 2007 +0200 @@ -172,17 +172,19 @@ struct index_mail_data *data = &mail->data; struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox; const struct mail_index_header *hdr; - struct istream *stream; - uoff_t hdr_offset, body_offset, body_size; - uoff_t next_offset; + struct istream *input; + struct message_size hdr_size; + uoff_t body_offset, body_size, next_offset; - if (mbox_mail_seek(mail) < 0) + if (index_mail_get_physical_size(_mail, size_r) == 0) + return 0; + + /* we want to return the header size as seen by mail_get_stream(). */ + if (mail_get_stream(_mail, &hdr_size, NULL, &input) < 0) return -1; /* our header size varies, so don't do any caching */ - stream = mbox->mbox_stream; - hdr_offset = istream_raw_mbox_get_header_offset(stream); - body_offset = istream_raw_mbox_get_body_offset(stream); + body_offset = istream_raw_mbox_get_body_offset(mbox->mbox_stream); if (body_offset == (uoff_t)-1) { mail_storage_set_critical(_mail->box->storage, "Couldn't get mbox size"); @@ -208,9 +210,10 @@ } /* verify that the calculated body size is correct */ - body_size = istream_raw_mbox_get_body_size(stream, body_size); + body_size = istream_raw_mbox_get_body_size(mbox->mbox_stream, + body_size); - data->physical_size = (body_offset - hdr_offset) + body_size; + data->physical_size = hdr_size.physical_size + body_size; *size_r = data->physical_size; return 0; }
--- a/src/lib-storage/mail-storage.h Fri Dec 21 21:39:58 2007 +0200 +++ b/src/lib-storage/mail-storage.h Fri Dec 21 22:58:11 2007 +0200 @@ -430,7 +430,7 @@ /* Get the space used by the mail as seen by the reader. Linefeeds are always counted as being CR+LF. */ int mail_get_virtual_size(struct mail *mail, uoff_t *size_r); -/* Get the space used by the mail in disk. */ +/* Get the size of the stream returned by mail_get_stream(). */ int mail_get_physical_size(struct mail *mail, uoff_t *size_r); /* Get value for single header field, or NULL if header wasn't found.