From: Timo Sirainen Date: Sat, 6 Feb 2010 21:22:04 +0000 (+0200) Subject: mdbox saving: Fallback to using non-exact mail size if exact isn't available. X-Git-Tag: 2.0.beta3~148 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e702db5540b2303e25554dee21bbf35a4813381;p=thirdparty%2Fdovecot%2Fcore.git mdbox saving: Fallback to using non-exact mail size if exact isn't available. The size is used only to check if it would make mdbox file become too large. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-save.c b/src/lib-storage/index/dbox-multi/mdbox-save.c index 9390353cc5..38ba3f808c 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-save.c +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c @@ -98,8 +98,16 @@ int mdbox_save_begin(struct mail_save_context *_ctx, struct istream *input) uoff_t mail_size, append_offset; /* get the size of the mail to be saved, if possible */ - if (i_stream_get_size(input, TRUE, &mail_size) <= 0) - mail_size = 0; + if (i_stream_get_size(input, TRUE, &mail_size) <= 0) { + const struct stat *st; + + /* we couldn't find out the exact size. fallback to non-exact, + maybe it'll give something useful. the mail size is used + only to figure out if it's causing mdbox file to grow + too large. */ + st = i_stream_stat(input, FALSE); + mail_size = st->st_size > 0 ? st->st_size : 0; + } if (dbox_map_append_next(ctx->append_ctx, mail_size, &ctx->cur_file_append, &ctx->ctx.cur_output) < 0) {