From: Timo Sirainen Date: Wed, 25 Jan 2012 22:37:42 +0000 (+0200) Subject: maildir: When saving mails compressed, make sure ,S=size gets added to the filename. X-Git-Tag: 2.1.rc5~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4199f701aa708cb5f7e20be6f6bc838f97efbd00;p=thirdparty%2Fdovecot%2Fcore.git maildir: When saving mails compressed, make sure ,S=size gets added to the filename. --- diff --git a/src/lib-storage/index/maildir/maildir-save.c b/src/lib-storage/index/maildir/maildir-save.c index f19e6a2943..ba23ff6120 100644 --- a/src/lib-storage/index/maildir/maildir-save.c +++ b/src/lib-storage/index/maildir/maildir-save.c @@ -515,6 +515,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) struct maildir_save_context *ctx = (struct maildir_save_context *)_ctx; struct mail_storage *storage = &ctx->mbox->storage->storage; const char *path; + off_t real_size; int output_errno; ctx->last_save_finished = TRUE; @@ -570,6 +571,15 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx) ctx->failed = TRUE; } } + real_size = lseek(ctx->fd, 0, SEEK_END); + if (real_size == (off_t)-1) { + mail_storage_set_critical(storage, + "lseek(%s) failed: %m", path); + } else if (real_size != (off_t)ctx->file_last->size) { + /* e.g. zlib plugin was used. the "physical size" must be in + the maildir filename, since stat() will return wrong size */ + ctx->file_last->preserve_filename = FALSE; + } if (close(ctx->fd) < 0) { if (!mail_storage_set_error_from_errno(storage)) { mail_storage_set_critical(storage,