dovecot-2.0: Maildir: Fixed accessing INBOX whose tmp/ directory...

dovecot at dovecot.org dovecot at dovecot.org
Sun Sep 26 20:36:49 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/5b0a1974fc6f
changeset: 12180:5b0a1974fc6f
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Sep 26 18:36:14 2010 +0100
description:
Maildir: Fixed accessing INBOX whose tmp/ directory was lost.

diffstat:

 src/lib-storage/index/maildir/maildir-storage.c |  36 ++++++++++-------
 1 files changed, 21 insertions(+), 15 deletions(-)

diffs (64 lines):

diff -r 45a62c8637e8 -r 5b0a1974fc6f src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Sun Sep 26 18:05:25 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Sun Sep 26 18:36:14 2010 +0100
@@ -235,27 +235,23 @@
 {
 	const char *path;
 	unsigned int i;
-	int ret;
-
-	if (!verify) {
-		ret = maildir_check_tmp(box->storage, box->path);
-		if (ret > 0) {
-			mail_storage_set_error(box->storage,
-				MAIL_ERROR_EXISTS, "Mailbox already exists");
-			return -1;
-		}
-		if (ret < 0)
-			return -1;
-	}
+	enum mail_error error;
+	int ret = 0;
 
 	for (i = 0; i < N_ELEMENTS(maildir_subdirs); i++) {
 		path = t_strconcat(box->path, "/", maildir_subdirs[i], NULL);
 		if (mkdir_verify(box->storage, box->list->ns, path,
 				 box->dir_create_mode, box->file_create_gid,
-				 box->file_create_gid_origin, verify) < 0)
-			return -1;
+				 box->file_create_gid_origin, verify) < 0) {
+			(void)mail_storage_get_last_error(box->storage, &error);
+			if (error != MAIL_ERROR_EXISTS)
+				return -1;
+			/* try to create all of the directories in case one
+			   of them doesn't exist */
+			ret = -1;
+		}
 	}
-	return 0;
+	return ret;
 }
 
 static void maildir_lock_touch_timeout(struct maildir_mailbox *mbox)
@@ -431,11 +427,21 @@
 {
 	const char *root_dir, *shared_path;
 	struct stat st;
+	int ret;
 
 	if (directory &&
 	    (box->list->props & MAILBOX_LIST_PROP_NO_NOSELECT) == 0)
 		return 0;
 
+	ret = maildir_check_tmp(box->storage, box->path);
+	if (ret > 0) {
+		mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS,
+				       "Mailbox already exists");
+		return -1;
+	}
+	if (ret < 0)
+		return -1;
+
 	if (create_maildir(box, FALSE) < 0)
 		return -1;
 


More information about the dovecot-cvs mailing list