[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c, 1.167, 1.168

tss at dovecot.org tss at dovecot.org
Sun May 13 21:28:45 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv25029/lib-storage/index/maildir

Modified Files:
	maildir-storage.c 
Log Message:
Moved index directory creation code to index_storage_alloc().



Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- maildir-storage.c	13 May 2007 17:10:52 -0000	1.167
+++ maildir-storage.c	13 May 2007 18:28:43 -0000	1.168
@@ -40,8 +40,7 @@
 static MODULE_CONTEXT_DEFINE_INIT(maildir_mailbox_list_module,
 				  &mailbox_list_module_register);
 
-static int verify_inbox(struct mail_storage *storage,
-			enum mailbox_open_flags *flags);
+static int verify_inbox(struct mail_storage *storage);
 static int
 maildir_list_delete_mailbox(struct mailbox_list *list, const char *name);
 static int
@@ -230,7 +229,6 @@
 	enum mail_storage_flags flags = _storage->flags;
 	struct mailbox_list_settings list_set;
 	struct mailbox_list *list;
-	enum mailbox_open_flags open_flags;
 	const char *layout, *error;
 	struct stat st;
 
@@ -287,8 +285,7 @@
 				    "tmp/", storage->temp_prefix, NULL);
 	}
 
-	open_flags = 0;
-	(void)verify_inbox(_storage, &open_flags);
+	(void)verify_inbox(_storage);
 	return 0;
 }
 
@@ -378,34 +375,6 @@
 	return 0;
 }
 
-static int create_index_dir(struct mail_storage *storage, const char *name)
-{
-	const char *index_dir, *root_dir, *dir;
-
-	index_dir = mailbox_list_get_path(storage->list, name,
-					  MAILBOX_LIST_PATH_TYPE_INDEX);
-	if (*index_dir == '\0')
-		return 0;
-
-	root_dir = mailbox_list_get_path(storage->list, name,
-					 MAILBOX_LIST_PATH_TYPE_MAILBOX);
-	if (strcmp(index_dir, root_dir) == 0)
-		return 0;
-
-	dir = t_strdup_printf("%s/%c%s", index_dir,
-			      mailbox_list_get_hierarchy_sep(storage->list),
-			      name);
-	if (mkdir_parents(dir, CREATE_MODE) < 0 && errno != EEXIST) {
-		if (!ENOSPACE(errno)) {
-			mail_storage_set_critical(storage,
-						  "mkdir(%s) failed: %m", dir);
-		}
-		return -1;
-	}
-
-	return 0;
-}
-
 static int create_control_dir(struct mail_storage *storage, const char *name)
 {
 	const char *control_dir, *root_dir, *dir;
@@ -429,8 +398,7 @@
 	return 0;
 }
 
-static int verify_inbox(struct mail_storage *storage,
-			enum mailbox_open_flags *flags)
+static int verify_inbox(struct mail_storage *storage)
 {
 	const char *path;
 
@@ -438,9 +406,6 @@
 				     MAILBOX_LIST_PATH_TYPE_MAILBOX);
 	if (create_maildir(storage, path, TRUE) < 0)
 		return -1;
-
-	if (create_index_dir(storage, "INBOX") < 0)
-		*flags |= MAILBOX_OPEN_NO_INDEX_FILES;
 	if (create_control_dir(storage, "INBOX") < 0)
 		return -1;
 	return 0;
@@ -464,22 +429,17 @@
 {
 	struct maildir_mailbox *mbox;
 	struct mail_index *index;
-	const char *path, *index_dir, *control_dir;
+	const char *path, *control_dir;
 	struct stat st;
 	int shared;
 	pool_t pool;
 
 	path = mailbox_list_get_path(storage->storage.list, name,
 				     MAILBOX_LIST_PATH_TYPE_MAILBOX);
-	index_dir = mailbox_list_get_path(storage->storage.list, name,
-					  MAILBOX_LIST_PATH_TYPE_INDEX);
 	control_dir = mailbox_list_get_path(storage->storage.list, name,
 					    MAILBOX_LIST_PATH_TYPE_CONTROL);
 
-	if ((flags & MAILBOX_OPEN_NO_INDEX_FILES) != 0)
-		index_dir = "";
-
-	index = index_storage_alloc(index_dir, path,
+	index = index_storage_alloc(&storage->storage, name, flags,
 				    MAILDIR_INDEX_PREFIX);
 
 	/* for shared mailboxes get the create mode from the
@@ -548,7 +508,7 @@
 	}
 
 	if (strcmp(name, "INBOX") == 0) {
-		if (verify_inbox(_storage, &flags) < 0)
+		if (verify_inbox(_storage) < 0)
 			return NULL;
 		return maildir_open(storage, "INBOX", flags);
 	}
@@ -561,11 +521,6 @@
 		    create_control_dir(_storage, name) < 0)
 			return NULL;
 
-		if ((flags & MAILBOX_OPEN_NO_INDEX_FILES) == 0) {
-			if (create_index_dir(_storage, name) < 0)
-				flags |= MAILBOX_OPEN_NO_INDEX_FILES;
-		}
-
 		return maildir_open(storage, name, flags);
 	} else if (errno == ENOENT) {
 		mail_storage_set_error(_storage, MAIL_ERROR_NOTFOUND,



More information about the dovecot-cvs mailing list