dovecot-2.1: maildir: When saving mails compressed, make sure ,S...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jan 26 00:37:52 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/8f25ff7e0e78
changeset: 13993:8f25ff7e0e78
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jan 26 00:37:42 2012 +0200
description:
maildir: When saving mails compressed, make sure ,S=size gets added to the filename.

diffstat:

 src/lib-storage/index/maildir/maildir-save.c |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r cfc395ee6be1 -r 8f25ff7e0e78 src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c	Wed Jan 25 23:45:02 2012 +0200
+++ b/src/lib-storage/index/maildir/maildir-save.c	Thu Jan 26 00:37:42 2012 +0200
@@ -515,6 +515,7 @@
 	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 @@
 			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,


More information about the dovecot-cvs mailing list