dovecot-2.2: maildir: Avoid duplicate S=size and W=sizes in mail...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 20 03:26:29 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/3599790da3d7
changeset: 14364:3599790da3d7
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Mar 21 14:25:12 2012 +0200
description:
maildir: Avoid duplicate S=size and W=sizes in maildir filenames.
This happens with maildir_copy_with_hardlinks=no and when copying a mail
with zlib compression enabled.

diffstat:

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

diffs (29 lines):

diff -r 23ed09ca847a -r 3599790da3d7 src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c	Wed Mar 21 13:43:56 2012 +0200
+++ b/src/lib-storage/index/maildir/maildir-save.c	Wed Mar 21 14:25:12 2012 +0200
@@ -516,6 +516,7 @@
 	struct mail_storage *storage = &ctx->mbox->storage->storage;
 	const char *path;
 	off_t real_size;
+	uoff_t size;
 	int output_errno;
 
 	ctx->last_save_finished = TRUE;
@@ -575,10 +576,16 @@
 	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) {
+	} else if (real_size != (off_t)ctx->file_last->size &&
+		   (!maildir_filename_get_size(ctx->file_last->dest_basename,
+					       MAILDIR_EXTRA_FILE_SIZE, &size) ||
+		    size != 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;
+		/* reset the base name as well, just in case there's a
+		   ,W=vsize */
+		ctx->file_last->dest_basename = ctx->file_last->tmp_name;
 	}
 	if (close(ctx->fd) < 0) {
 		if (!mail_storage_set_error_from_errno(storage)) {


More information about the dovecot-cvs mailing list