[dovecot-cvs] dovecot/src/lib-index/maildir Makefile.am,1.4,1.5 maildir-build.c,1.20,1.21 maildir-index.h,1.16,1.17 maildir-update.c,1.15,NONE

cras at procontrol.fi cras at procontrol.fi
Wed Apr 16 17:57:23 EEST 2003


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

Modified Files:
	Makefile.am maildir-build.c maildir-index.h 
Removed Files:
	maildir-update.c 
Log Message:
If we don't want to precache anything, don't open the file at all when
building index.



Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am	9 Apr 2003 20:39:37 -0000	1.4
+++ Makefile.am	16 Apr 2003 13:57:21 -0000	1.5
@@ -13,8 +13,7 @@
 	maildir-open.c \
 	maildir-rebuild.c \
 	maildir-sync.c \
-	maildir-uidlist.c \
-	maildir-update.c
+	maildir-uidlist.c
 
 noinst_HEADERS = \
 	maildir-index.h \

Index: maildir-build.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-build.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- maildir-build.c	9 Apr 2003 20:10:01 -0000	1.20
+++ maildir-build.c	16 Apr 2003 13:57:21 -0000	1.21
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "lib.h"
+#include "istream.h"
 #include "str.h"
 #include "maildir-index.h"
 #include "mail-index-data.h"
@@ -12,6 +13,27 @@
 #include <dirent.h>
 #include <sys/stat.h>
 
+static int maildir_record_update(struct mail_index *index,
+				 struct mail_index_update *update, int fd)
+{
+	struct istream *input;
+        enum mail_data_field cache_fields;
+
+	if (index->mail_read_mmaped) {
+		input = i_stream_create_mmap(fd, system_pool,
+					     MAIL_MMAP_BLOCK_SIZE, 0, 0, FALSE);
+	} else {
+		input = i_stream_create_file(fd, system_pool,
+					     MAIL_READ_BLOCK_SIZE, FALSE);
+	}
+
+	cache_fields = index->header->cache_fields & ~DATA_FIELD_LOCATION;
+	mail_index_update_headers(update, input, cache_fields, NULL, NULL);
+
+	i_stream_unref(input);
+	return TRUE;
+}
+
 static int maildir_index_append_fd(struct mail_index *index,
 				   int fd, const char *fname)
 {
@@ -83,8 +105,10 @@
 
 	i_assert(index->lock_type != MAIL_LOCK_SHARED);
 
-	i_assert(dir != NULL);
-	i_assert(fname != NULL);
+	if ((index->header->cache_fields & ~DATA_FIELD_LOCATION) == 0) {
+		/* nothing cached, don't bother opening the file */
+		return maildir_index_append_fd(index, -1, fname);
+	}
 
 	path = t_strconcat(dir, "/", fname, NULL);
 	fd = open(path, O_RDONLY);

Index: maildir-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-index.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- maildir-index.h	9 Apr 2003 20:10:01 -0000	1.16
+++ maildir-index.h	16 Apr 2003 13:57:21 -0000	1.17
@@ -35,9 +35,6 @@
 				  struct mail_index_record *rec,
 				  time_t *internal_date, int *deleted);
 
-int maildir_record_update(struct mail_index *index,
-			  struct mail_index_update *update, int fd);
-
 void maildir_clean_tmp(const char *dir);
 
 #endif

--- maildir-update.c DELETED ---




More information about the dovecot-cvs mailing list