dovecot: If mailbox is deleted while it's being created, don't l...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 19 03:37:48 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/b6a477859a3c
changeset: 6095:b6a477859a3c
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 19 03:34:08 2007 +0300
description:
If mailbox is deleted while it's being created, don't log an error.

diffstat:

1 file changed, 26 insertions(+), 25 deletions(-)
src/lib-storage/index/maildir/maildir-storage.c |   51 +++++++++++------------

diffs (81 lines):

diff -r b9f7eb84d4be -r b6a477859a3c src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Thu Jul 19 03:11:21 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Thu Jul 19 03:34:08 2007 +0300
@@ -333,17 +333,22 @@ static int mkdir_verify(struct mail_stor
 		}
 	}
 
-	if (mkdir_parents(dir, CREATE_MODE) < 0) {
-		if (errno == EEXIST) {
-			if (!verify)
-				return -1;
-		} else {
-			mail_storage_set_critical(storage,
-						  "mkdir(%s) failed: %m", dir);
-			return -1;
-		}
-	}
-	return 0;
+	if (mkdir_parents(dir, CREATE_MODE) == 0)
+		return 0;
+
+	if (errno == EEXIST) {
+		if (verify)
+			return 0;
+		mail_storage_set_error(storage, MAIL_ERROR_NOTPOSSIBLE,
+				       "Mailbox already exists");
+	} else if (errno == ENOENT) {
+		mail_storage_set_error(storage, MAIL_ERROR_NOTFOUND,
+			"Mailbox was deleted while it was being created");
+	} else {
+		mail_storage_set_critical(storage,
+					  "mkdir(%s) failed: %m", dir);
+	}
+	return -1;
 }
 
 /* create or fix maildir, ignore if it already exists */
@@ -552,10 +557,6 @@ static int maildir_create_shared(struct 
 
 	old_mask = umask(0777 ^ mode);
 	if (create_maildir(storage, dir, FALSE) < 0) {
-		if (errno == EEXIST) {
-			mail_storage_set_error(storage, MAIL_ERROR_NOTPOSSIBLE,
-					       "Mailbox already exists");
-		}
 		umask(old_mask);
 		return -1;
 	}
@@ -601,22 +602,22 @@ static int maildir_mailbox_create(struct
 					     st.st_mode & 0666, st.st_gid);
 	}
 
-	if (create_maildir(_storage, path, FALSE) < 0) {
-		if (errno == EEXIST) {
-			mail_storage_set_error(_storage, MAIL_ERROR_NOTPOSSIBLE,
-					       "Mailbox already exists");
-		}
-		return -1;
-	}
+	if (create_maildir(_storage, path, FALSE) < 0)
+		return -1;
 
 	/* Maildir++ spec want that maildirfolder named file is created for
 	   all subfolders. */
 	path = t_strconcat(path, "/" MAILDIR_SUBFOLDER_FILENAME, NULL);
 	fd = open(path, O_CREAT | O_WRONLY, CREATE_MODE & 0666);
-	if (fd == -1)
+	if (fd != -1)
+		(void)close(fd);
+	else if (errno == ENOENT) {
+		mail_storage_set_error(_storage, MAIL_ERROR_NOTFOUND,
+			"Mailbox was deleted while it was being created");
+		return -1;
+	} else {
 		i_error("open(%s, O_CREAT) failed: %m", path);
-	else
-		(void)close(fd);
+	}
 	return 0;
 }
 


More information about the dovecot-cvs mailing list