]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
If we don't want to precache anything, don't open the file at all when
authorTimo Sirainen <tss@iki.fi>
Wed, 16 Apr 2003 13:57:21 +0000 (16:57 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 16 Apr 2003 13:57:21 +0000 (16:57 +0300)
building index.

--HG--
branch : HEAD

src/lib-index/maildir/Makefile.am
src/lib-index/maildir/maildir-build.c
src/lib-index/maildir/maildir-index.h
src/lib-index/maildir/maildir-update.c [deleted file]

index c796003e2195f334e53db62e43ae793ebf66732f..e581285e94ba57a5849e8c5ee0f46a0e291f13df 100644 (file)
@@ -13,8 +13,7 @@ libstorage_index_maildir_a_SOURCES = \
        maildir-open.c \
        maildir-rebuild.c \
        maildir-sync.c \
-       maildir-uidlist.c \
-       maildir-update.c
+       maildir-uidlist.c
 
 noinst_HEADERS = \
        maildir-index.h \
index 3eefb0ea0b06ac657a032bceb9688c2913422d11..8d75d0189b866a672d8562a570b8b2adc454831e 100644 (file)
@@ -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"
 #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 @@ int maildir_index_append_file(struct mail_index *index, const char *dir,
 
        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 86f6aa60737b5dc12e7c4dc1d4c9e9312803b0ce..1a2f0fe2d1befff893b96a02b5b61553b0a2ec53 100644 (file)
@@ -35,9 +35,6 @@ struct istream *maildir_open_mail(struct mail_index *index,
                                  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
diff --git a/src/lib-index/maildir/maildir-update.c b/src/lib-index/maildir/maildir-update.c
deleted file mode 100644 (file)
index c32e700..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2002 Timo Sirainen */
-
-#include "lib.h"
-#include "istream.h"
-#include "maildir-index.h"
-
-int maildir_record_update(struct mail_index *index,
-                         struct mail_index_update *update, int fd)
-{
-       struct istream *input;
-        enum mail_data_field cache_fields;
-
-       /* don't even bother opening the file if we're not going to do
-          anything */
-       cache_fields = index->header->cache_fields & ~DATA_FIELD_LOCATION;
-       if (cache_fields == 0)
-               return TRUE;
-
-       t_push();
-       if (index->mail_read_mmaped) {
-               input = i_stream_create_mmap(fd, data_stack_pool,
-                                            MAIL_MMAP_BLOCK_SIZE, 0, 0, FALSE);
-       } else {
-               input = i_stream_create_file(fd, data_stack_pool,
-                                            MAIL_READ_BLOCK_SIZE, FALSE);
-       }
-       mail_index_update_headers(update, input, cache_fields, NULL, NULL);
-       i_stream_unref(input);
-       t_pop();
-       return TRUE;
-}