[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c,1.41,1.42

cras at procontrol.fi cras at procontrol.fi
Sun Feb 23 23:07:00 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory danu:/tmp/cvs-serv1249/src/lib-storage/index/mbox

Modified Files:
	mbox-storage.c 
Log Message:
Index opening rewrites. We don't try to support .imap.index-<hostname> style
indexes anymore. They just made things more difficult, and it's really not a
good idea to use index files via NFS anyway.

Added support for :INDEX=MEMORY in MAIL env to disable using index files.
Also if we can't open or create index file for any reason, we now fallback
to in-memory indexes. Before we fallbacked only with out of disk space
errors.

If .customflags can't be created, we still work now by not allowing to
create new custom flags.



Index: mbox-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- mbox-storage.c	20 Feb 2003 10:52:11 -0000	1.41
+++ mbox-storage.c	23 Feb 2003 21:06:57 -0000	1.42
@@ -54,6 +54,8 @@
 	const char *path;
 	struct stat st;
 
+	data = t_strcut(data, ':');
+
 	/* Is it INBOX file? */
 	if (*data != '\0' && stat(data, &st) == 0 && !S_ISDIR(st.st_mode) &&
 	    access(data, R_OK|W_OK) == 0)
@@ -191,8 +193,11 @@
 
 	if (inbox_file == NULL)
 		inbox_file = get_inbox_file(root_dir, !autodetect);
+
 	if (index_dir == NULL)
 		index_dir = root_dir;
+	else if (strcmp(index_dir, "MEMORY") == 0)
+		index_dir = NULL;
 
 	storage = i_new(struct mail_storage, 1);
 	memcpy(storage, &mbox_storage, sizeof(struct mail_storage));
@@ -254,6 +259,9 @@
 {
 	const char *p;
 
+	if (storage->index_dir == NULL)
+		return NULL;
+
 	if (full_filesystem_access && (*name == '/' || *name == '~')) {
 		name = home_expand(name);
 		p = strrchr(name, '/');
@@ -277,6 +285,9 @@
 	const char *index_dir, *imap_dir;
 
 	index_dir = mbox_get_index_dir(storage, name);
+	if (index_dir == NULL)
+		return TRUE;
+
 	imap_dir = t_strdup_until(index_dir, strstr(index_dir, ".imap/") + 5);
 
 	if (mkdir(imap_dir, CREATE_MODE) == -1 && errno != EEXIST)
@@ -333,6 +344,7 @@
 	index = index_storage_lookup_ref(index_dir);
 	if (index == NULL) {
 		index = mbox_index_alloc(index_dir, path);
+		index->custom_flags_dir = i_strdup(index_dir);
 		index_storage_add(index);
 	}
 
@@ -511,7 +523,8 @@
 
 	/* next delete the index directory */
 	index_dir = mbox_get_index_dir(storage, name);
-	if (unlink_directory(index_dir, TRUE) < 0 && errno != ENOENT) {
+	if (index_dir != NULL &&
+	    unlink_directory(index_dir, TRUE) < 0 && errno != ENOENT) {
 		mail_storage_set_critical(storage, "unlink_directory(%s) "
 					  "failed: %m", index_dir);
 		return FALSE;
@@ -566,7 +579,8 @@
 	/* we need to rename the index directory as well */
 	old_indexdir = mbox_get_index_dir(storage, oldname);
 	new_indexdir = mbox_get_index_dir(storage, newname);
-	(void)rename(old_indexdir, new_indexdir);
+	if (old_indexdir != NULL)
+		(void)rename(old_indexdir, new_indexdir);
 
 	return TRUE;
 }




More information about the dovecot-cvs mailing list