From: Timo Sirainen Date: Wed, 4 Aug 2010 15:15:48 +0000 (+0100) Subject: maildir: When copying can't preserve filename, preserve S/W sizes anyway. X-Git-Tag: 2.0.rc4~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9d2739ae2dc5c9347b0c313b3c8125e7ed2a8cb;p=thirdparty%2Fdovecot%2Fcore.git maildir: When copying can't preserve filename, preserve S/W sizes anyway. --- diff --git a/src/lib-storage/index/maildir/maildir-save.c b/src/lib-storage/index/maildir/maildir-save.c index 7f7821b1d7..bfb4204651 100644 --- a/src/lib-storage/index/maildir/maildir-save.c +++ b/src/lib-storage/index/maildir/maildir-save.c @@ -764,6 +764,8 @@ static void 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 @@ maildir_filename_check_conflicts(struct maildir_save_context *ctx, 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; } }