changeset 11928:33ea7477c6a9

maildir: When copying can't preserve filename, preserve S/W sizes anyway.
author Timo Sirainen <tss@iki.fi>
date Wed, 04 Aug 2010 16:15:48 +0100
parents 353d73775b69
children e9cc262e4bbb
files src/lib-storage/index/maildir/maildir-save.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-save.c	Wed Aug 04 16:02:54 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-save.c	Wed Aug 04 16:15:48 2010 +0100
@@ -764,6 +764,8 @@
 maildir_filename_check_conflicts(struct maildir_save_context *ctx,
 				 struct maildir_filename *mf)
 {
+	uoff_t size;
+
 	if (!ctx->locked_uidlist_refresh) {
 		(void)maildir_uidlist_refresh(ctx->mbox->uidlist);
 		ctx->locked_uidlist_refresh = TRUE;
@@ -771,9 +773,19 @@
 
 	if (maildir_uidlist_get_full_filename(ctx->mbox->uidlist,
 					      mf->dest_basename) != NULL) {
-		/* file already exists. give it another name. */
+		/* file already exists. give it another name.
+		   but preserve the size/vsize in the filename if possible */
+		if (maildir_filename_get_size(mf->dest_basename,
+					      MAILDIR_EXTRA_FILE_SIZE, &size))
+			mf->size = size;
+		if (maildir_filename_get_size(mf->dest_basename,
+					      MAILDIR_EXTRA_VIRTUAL_SIZE,
+					      &size))
+			mf->vsize = size;
+
 		mf->dest_basename = p_strdup(ctx->pool,
 					     maildir_filename_generate());
+		mf->preserve_filename = FALSE;
 	}
 }