[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c,
1.60, 1.61 index-mail.c, 1.97, 1.98 index-mail.h, 1.38, 1.39
tss-movial at dovecot.org
tss-movial at dovecot.org
Tue May 9 14:57:39 EEST 2006
- Previous message: [dovecot-cvs] dovecot/src/lib-storage mail-copy.c, 1.7,
1.8 mail-storage-private.h, 1.25, 1.26 mail-storage.c, 1.50,
1.51 mail-storage.h, 1.107, 1.108
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-save.c, 1.10,
1.11 dbox-storage.h, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv603/lib-storage/index
Modified Files:
index-mail-headers.c index-mail.c index-mail.h
Log Message:
Changed mailbox_save_*() API a bit: Moved the struct mail *dest_mail to
save_init() instead of being in save_finish(). This way you can request
wanted fields from the mail while it's being saved.
With maildir the message is being parsed at the same time as it's being
saved, and the results are stored into cache file.
Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- index-mail-headers.c 8 May 2006 08:46:22 -0000 1.60
+++ index-mail-headers.c 9 May 2006 11:57:37 -0000 1.61
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Timo Sirainen */
+/* Copyright (C) 2003-2006 Timo Sirainen */
#include "lib.h"
#include "istream.h"
@@ -247,7 +247,6 @@
struct index_mail *mail)
{
struct index_mail_data *data = &mail->data;
- enum mail_cache_decision_type decision;
const char *cache_field_name;
unsigned int field_idx, count;
uint8_t *match;
@@ -295,17 +294,9 @@
}
if (!hdr->continued) {
- decision = mail_cache_field_get_decision(mail->ibox->cache,
- field_idx);
data->parse_line.cache =
- (decision & ~MAIL_CACHE_DECISION_FORCED) !=
- MAIL_CACHE_DECISION_NO;
- if (data->parse_line.cache &&
- mail_cache_field_exists(mail->trans->cache_view,
- data->seq, field_idx) > 0) {
- /* already cached */
- data->parse_line.cache = FALSE;
- }
+ mail_cache_field_want_add(mail->trans->cache_trans,
+ data->seq, field_idx);
}
match = array_get_modifyable(&mail->header_match, &count);
Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- index-mail.c 8 May 2006 13:04:10 -0000 1.97
+++ index-mail.c 9 May 2006 11:57:37 -0000 1.98
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2003 Timo Sirainen */
+/* Copyright (C) 2002-2006 Timo Sirainen */
#include "lib.h"
#include "array.h"
@@ -501,11 +501,11 @@
else if (field == MAIL_CACHE_IMAP_BODY) {
cache_body =
mail_cache_field_can_add(mail->trans->cache_trans,
- data->seq, cache_field_bodystructure);
+ data->seq, cache_field_body);
} else {
cache_body =
mail_cache_field_want_add(mail->trans->cache_trans,
- data->seq, cache_field_bodystructure);
+ data->seq, cache_field_body);
}
if (field == MAIL_CACHE_IMAP_BODY || cache_body) {
@@ -520,17 +520,38 @@
}
}
+static void
+index_mail_body_parsed_cache_virtual_size(struct index_mail *mail)
+{
+ unsigned int cache_field =
+ mail->ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;
+
+ if (mail_cache_field_want_add(mail->trans->cache_trans,
+ mail->data.seq, cache_field)) {
+ index_mail_cache_add(mail, cache_field,
+ &mail->data.virtual_size,
+ sizeof(mail->data.virtual_size));
+ }
+}
+
static void index_mail_parse_body_finish(struct index_mail *mail,
- enum index_cache_field field)
+ enum index_cache_field field,
+ bool appended_mail)
{
mail->data.parts = message_parser_deinit(&mail->data.parser_ctx);
- mail->data.body_size = mail->data.parts->body_size;
- mail->data.body_size_set = TRUE;
+ if (appended_mail) {
+ bool use_crlf = (mail->ibox->box.storage->flags &
+ MAIL_STORAGE_FLAG_SAVE_CRLF) != 0;
+ message_parser_set_crlfs(mail->data.parts, use_crlf);
+ }
+
+ (void)get_cached_msgpart_sizes(mail);
index_mail_body_parsed_cache_flags(mail);
index_mail_body_parsed_cache_message_parts(mail);
index_mail_body_parsed_cache_bodystructure(mail, field);
+ index_mail_body_parsed_cache_virtual_size(mail);
}
static void index_mail_parse_body(struct index_mail *mail,
@@ -555,7 +576,7 @@
} else {
message_parser_parse_body(data->parser_ctx, NULL, NULL);
}
- index_mail_parse_body_finish(mail, field);
+ index_mail_parse_body_finish(mail, field, FALSE);
}
struct istream *index_mail_init_stream(struct index_mail *_mail,
@@ -981,6 +1002,47 @@
pool_unref(mail->mail.pool);
}
+void index_mail_cache_parse_init(struct mail *_mail, struct istream *input)
+{
+ struct index_mail *mail = (struct index_mail *)_mail;
+
+ i_assert(mail->data.parser_ctx == NULL);
+
+ index_mail_parse_header_init(mail, NULL);
+ mail->data.parser_ctx = message_parser_init(mail->data_pool, input);
+}
+
+void index_mail_cache_parse_continue(struct mail *_mail)
+{
+ struct index_mail *mail = (struct index_mail *)_mail;
+ struct message_block block;
+ int ret;
+
+ while ((ret = message_parser_parse_next_block(mail->data.parser_ctx,
+ &block)) > 0) {
+ if (block.size != 0)
+ continue;
+
+ if (!mail->data.header_parsed) {
+ index_mail_parse_header(block.part, block.hdr, mail);
+ if (block.hdr == NULL)
+ mail->data.header_parsed = TRUE;
+ } else {
+ imap_bodystructure_parse_header(mail->data_pool,
+ block.part, block.hdr);
+ }
+ }
+}
+
+void index_mail_cache_parse_deinit(struct mail *_mail)
+{
+ struct index_mail *mail = (struct index_mail *)_mail;
+
+ mail->data.save_bodystructure_body = FALSE;
+ mail->data.parsed_bodystructure = TRUE;
+ index_mail_parse_body_finish(mail, 0, TRUE);
+}
+
int index_mail_update_flags(struct mail *mail, enum modify_type modify_type,
enum mail_flags flags)
{
Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- index-mail.h 8 May 2006 12:50:22 -0000 1.38
+++ index-mail.h 9 May 2006 11:57:37 -0000 1.39
@@ -101,6 +101,7 @@
unsigned int hdr_size_set:1;
unsigned int body_size_set:1;
unsigned int messageparts_saved_to_cache:1;
+ unsigned int header_parsed:1;
};
struct index_mail {
@@ -174,4 +175,8 @@
void index_mail_cache_add(struct index_mail *mail, unsigned int field,
const void *data, size_t data_size);
+void index_mail_cache_parse_init(struct mail *mail, struct istream *input);
+void index_mail_cache_parse_continue(struct mail *mail);
+void index_mail_cache_parse_deinit(struct mail *mail);
+
#endif
- Previous message: [dovecot-cvs] dovecot/src/lib-storage mail-copy.c, 1.7,
1.8 mail-storage-private.h, 1.25, 1.26 mail-storage.c, 1.50,
1.51 mail-storage.h, 1.107, 1.108
- Next message: [dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-save.c, 1.10,
1.11 dbox-storage.h, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list