[dovecot-cvs] dovecot/src/lib-index/maildir maildir-index.c,1.18,1.19 maildir-index.h,1.11,1.12 maildir-open.c,1.12,1.13 maildir-rebuild.c,1.7,1.8 maildir-sync.c,1.20,1.21

cras at procontrol.fi cras at procontrol.fi
Fri Dec 20 09:53:54 EET 2002


Update of /home/cvs/dovecot/src/lib-index/maildir
In directory danu:/tmp/cvs-serv29331/src/lib-index/maildir

Modified Files:
	maildir-index.c maildir-index.h maildir-open.c 
	maildir-rebuild.c maildir-sync.c 
Log Message:
Added :INDEX=<dir> for both Maildir and mbox to specify different location
where to store index files. This would allow keeping mailboxes accessible
through NFS but still keep the indexes in fast local disk.

Did also some other related cleanups and minor fixes.



Index: maildir-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-index.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- maildir-index.c	20 Dec 2002 07:37:37 -0000	1.18
+++ maildir-index.c	20 Dec 2002 07:53:52 -0000	1.19
@@ -133,15 +133,17 @@
 	return flags_str->str;
 }
 
-MailIndex *maildir_index_alloc(const char *dir)
+MailIndex *maildir_index_alloc(const char *dir, const char *maildir)
 {
 	MailIndex *index;
 
 	i_assert(dir != NULL);
+	i_assert(maildir != NULL);
 
 	index = i_new(MailIndex, 1);
 	memcpy(index, &maildir_index, sizeof(MailIndex));
 
+	index->mailbox_path = i_strdup(maildir);
 	mail_index_init(index, dir);
 	return index;
 }
@@ -150,6 +152,7 @@
 {
 	mail_index_close(index);
 	i_free(index->dir);
+	i_free(index->mailbox_path);
 	i_free(index);
 }
 
@@ -199,8 +202,10 @@
 	new_fname = maildir_filename_set_flags(old_fname, flags);
 
 	if (strcmp(old_fname, new_fname) != 0) {
-		old_path = t_strconcat(index->dir, "/cur/", old_fname, NULL);
-		new_path = t_strconcat(index->dir, "/cur/", new_fname, NULL);
+		old_path = t_strconcat(index->mailbox_path,
+				       "/cur/", old_fname, NULL);
+		new_path = t_strconcat(index->mailbox_path,
+				       "/cur/", new_fname, NULL);
 
 		/* minor problem: new_path is overwritten if it exists.. */
 		if (rename(old_path, new_path) < 0) {

Index: maildir-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-index.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- maildir-index.h	6 Dec 2002 01:09:23 -0000	1.11
+++ maildir-index.h	20 Dec 2002 07:53:52 -0000	1.12
@@ -6,7 +6,7 @@
 /* ":2,DFRST" - leave the 2 extra for other clients' additions */
 #define MAILDIR_LOCATION_EXTRA_SPACE 10
 
-MailIndex *maildir_index_alloc(const char *dir);
+MailIndex *maildir_index_alloc(const char *dir, const char *maildir);
 
 MailFlags maildir_filename_get_flags(const char *fname,
 				     MailFlags default_flags);

Index: maildir-open.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-open.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- maildir-open.c	6 Dec 2002 01:09:23 -0000	1.12
+++ maildir-open.c	20 Dec 2002 07:53:52 -0000	1.13
@@ -32,7 +32,7 @@
 		return NULL;
 	}
 
-	path = t_strconcat(index->dir, "/cur/", fname, NULL);
+	path = t_strconcat(index->mailbox_path, "/cur/", fname, NULL);
 	fd = open(path, O_RDONLY);
 	if (fd == -1) {
 		if (errno == ENOENT) {

Index: maildir-rebuild.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-rebuild.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- maildir-rebuild.c	27 Oct 2002 06:37:18 -0000	1.7
+++ maildir-rebuild.c	20 Dec 2002 07:53:52 -0000	1.8
@@ -39,12 +39,12 @@
 		return FALSE;
 
 	/* rebuild cur/ directory */
-	cur_dir = t_strconcat(index->dir, "/cur", NULL);
+	cur_dir = t_strconcat(index->mailbox_path, "/cur", NULL);
 	if (!maildir_index_build_dir(index, cur_dir, NULL))
 		return FALSE;
 
 	/* also see if there's new mail */
-	new_dir = t_strconcat(index->dir, "/new", NULL);
+	new_dir = t_strconcat(index->mailbox_path, "/new", NULL);
 	if (!maildir_index_build_dir(index, new_dir, cur_dir))
 		return FALSE;
 

Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-sync.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- maildir-sync.c	19 Dec 2002 01:02:35 -0000	1.20
+++ maildir-sync.c	20 Dec 2002 07:53:52 -0000	1.21
@@ -284,7 +284,7 @@
 	/* cur/ and new/ directories can have new mail - sync the cur/ first
 	   so it'll be a bit bit faster since we haven't yet added the new
 	   mail. */
-        cur_dir = t_strconcat(index->dir, "/cur", NULL);
+        cur_dir = t_strconcat(index->mailbox_path, "/cur", NULL);
 	if (stat(cur_dir, &std) < 0)
 		return index_file_set_syscall_error(index, cur_dir, "stat()");
 
@@ -295,7 +295,7 @@
 	}
 
 	/* move mail from new/ to cur/ */
-	new_dir = t_strconcat(index->dir, "/new", NULL);
+	new_dir = t_strconcat(index->mailbox_path, "/new", NULL);
 	if (stat(new_dir, &std) < 0)
 		return index_file_set_syscall_error(index, new_dir, "stat()");
 




More information about the dovecot-cvs mailing list