dovecot-2.0: Maildir saving: If GUID is specified, try to preser...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 24 23:42:20 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/a1535b151afa
changeset: 9527:a1535b151afa
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 24 16:42:15 2009 -0400
description:
Maildir saving: If GUID is specified, try to preserve it in the filename.

diffstat:

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

diffs (51 lines):

diff -r c8ff1a3722b7 -r a1535b151afa src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c	Wed Jun 24 14:20:11 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-save.c	Wed Jun 24 16:42:15 2009 -0400
@@ -285,12 +285,12 @@ const char *maildir_save_file_get_path(s
 }
 
 static int maildir_create_tmp(struct maildir_mailbox *mbox, const char *dir,
-			      const char **fname_r)
+			      const char **fname)
 {
 	struct mailbox *box = &mbox->ibox.box;
 	struct stat st;
 	unsigned int prefix_len;
-	const char *tmp_fname = NULL;
+	const char *tmp_fname = *fname;
 	string_t *path;
 	int fd;
 
@@ -300,7 +300,8 @@ static int maildir_create_tmp(struct mai
 	prefix_len = str_len(path);
 
 	for (;;) {
-		tmp_fname = maildir_filename_generate();
+		if (tmp_fname == NULL)
+			tmp_fname = maildir_filename_generate();
 		str_truncate(path, prefix_len);
 		str_append(path, tmp_fname);
 
@@ -325,9 +326,10 @@ static int maildir_create_tmp(struct mai
 			/* race condition between stat() and open().
 			   highly unlikely. */
 		}
-	}
-
-	*fname_r = tmp_fname;
+		tmp_fname = NULL;
+	}
+
+	*fname = tmp_fname;
 	if (fd == -1) {
 		if (ENOSPACE(errno)) {
 			mail_storage_set_error(box->storage,
@@ -371,7 +373,7 @@ int maildir_save_begin(struct mail_save_
 
 	T_BEGIN {
 		/* create a new file in tmp/ directory */
-		const char *fname = NULL;
+		const char *fname = _ctx->guid;
 
 		ctx->fd = maildir_create_tmp(ctx->mbox, ctx->tmpdir, &fname);
 		if (ctx->fd == -1)


More information about the dovecot-cvs mailing list