Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7241:a6c066f50877 HEAD
Added mail_set_cache_corrupted() to rebuild the cache file and force
recalculating the given field.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 14 Feb 2008 22:34:39 +0200 |
parents | fcfe2ea5c3ed |
children | 8cfa61f98e32 |
files | src/lib-storage/index/cydir/cydir-mail.c src/lib-storage/index/dbox/dbox-mail.c src/lib-storage/index/index-mail.c src/lib-storage/index/index-mail.h src/lib-storage/index/index-search.c src/lib-storage/index/maildir/maildir-mail.c src/lib-storage/index/mbox/mbox-mail.c src/lib-storage/index/raw/raw-mail.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.h src/lib-storage/mail.c |
diffstat | 11 files changed, 61 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/cydir/cydir-mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/cydir/cydir-mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -135,5 +135,6 @@ index_mail_get_special, index_mail_update_flags, index_mail_update_keywords, - index_mail_expunge + index_mail_expunge, + index_mail_set_cache_corrupted };
--- a/src/lib-storage/index/dbox/dbox-mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/dbox/dbox-mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -222,5 +222,6 @@ index_mail_get_special, index_mail_update_flags, index_mail_update_keywords, - index_mail_expunge + index_mail_expunge, + index_mail_set_cache_corrupted };
--- a/src/lib-storage/index/index-mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/index-mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -909,10 +909,8 @@ data->body = str_c(str); else { /* broken, continue.. */ - mail_cache_set_corrupted(mail->ibox->cache, - "Corrupted BODYSTRUCTURE for mail %u", - mail->mail.mail.uid); - data->bodystructure = NULL; + mail_set_cache_corrupted(_mail, + MAIL_FETCH_IMAP_BODYSTRUCTURE); } } @@ -1320,3 +1318,34 @@ mail_index_expunge(imail->trans->trans, mail->seq); } + +void index_mail_set_cache_corrupted(struct mail *mail, + enum mail_fetch_field field) +{ + struct index_mail *imail = (struct index_mail *)mail; + const char *field_name; + + switch (field) { + case MAIL_FETCH_MESSAGE_PARTS: + field_name = "MIME parts"; + imail->data.parts = NULL; + break; + case MAIL_FETCH_IMAP_BODY: + field_name = "IMAP BODY"; + imail->data.body = NULL; + imail->data.bodystructure = NULL; + break; + case MAIL_FETCH_IMAP_BODYSTRUCTURE: + field_name = "IMAP BODYSTRUCTURE"; + imail->data.body = NULL; + imail->data.bodystructure = NULL; + break; + default: + field_name = t_strdup_printf("#%x", field); + } + + mail_cache_set_corrupted(imail->ibox->cache, + "Broken %s for mail UID %u", + field_name, mail->uid); + +}
--- a/src/lib-storage/index/index-mail.h Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/index-mail.h Thu Feb 14 22:34:39 2008 +0200 @@ -191,6 +191,8 @@ void index_mail_update_keywords(struct mail *mail, enum modify_type modify_type, struct mail_keywords *keywords); void index_mail_expunge(struct mail *mail); +void index_mail_set_cache_corrupted(struct mail *mail, + enum mail_fetch_field field); bool index_mail_get_cached_uoff_t(struct index_mail *mail, enum index_cache_field field, uoff_t *size_r);
--- a/src/lib-storage/index/index-search.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/index-search.c Thu Feb 14 22:34:39 2008 +0200 @@ -478,18 +478,14 @@ i_stream_seek(ctx->input, 0); ret = message_search_msg(msg_search_ctx, ctx->input, ctx->part); - if (ret < 0) { - mail_cache_set_corrupted(ctx->index_ctx->ibox->cache, - "Broken message structure for mail UID %u", - ctx->index_ctx->mail->uid); - - /* get the body parts, and try again */ - ctx->index_ctx->imail->data.parts = NULL; + if (ret < 0 && ctx->input->stream_errno == 0) { + /* try again without cached parts */ + mail_set_cache_corrupted(ctx->index_ctx->mail, + MAIL_FETCH_MESSAGE_PARTS); i_stream_seek(ctx->input, 0); ret = message_search_msg(msg_search_ctx, ctx->input, NULL); - if (ret < 0) - i_panic("Couldn't fix broken body structure"); + i_assert(ret >= 0 || ctx->input->stream_errno != 0); } ARG_SET_RESULT(arg, ret > 0);
--- a/src/lib-storage/index/maildir/maildir-mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/maildir/maildir-mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -440,5 +440,6 @@ maildir_mail_get_special, index_mail_update_flags, index_mail_update_keywords, - index_mail_expunge + index_mail_expunge, + index_mail_set_cache_corrupted };
--- a/src/lib-storage/index/mbox/mbox-mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/mbox/mbox-mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -291,5 +291,6 @@ mbox_mail_get_special, index_mail_update_flags, index_mail_update_keywords, - index_mail_expunge + index_mail_expunge, + index_mail_set_cache_corrupted };
--- a/src/lib-storage/index/raw/raw-mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/index/raw/raw-mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -125,5 +125,6 @@ raw_mail_get_special, index_mail_update_flags, index_mail_update_keywords, - index_mail_expunge + index_mail_expunge, + index_mail_set_cache_corrupted };
--- a/src/lib-storage/mail-storage-private.h Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/mail-storage-private.h Thu Feb 14 22:34:39 2008 +0200 @@ -238,6 +238,8 @@ void (*update_keywords)(struct mail *mail, enum modify_type modify_type, struct mail_keywords *keywords); void (*expunge)(struct mail *mail); + void (*set_cache_corrupted)(struct mail *mail, + enum mail_fetch_field field); }; union mail_module_context {
--- a/src/lib-storage/mail-storage.h Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/mail-storage.h Thu Feb 14 22:34:39 2008 +0200 @@ -467,5 +467,7 @@ /* Expunge this message. Sequence numbers don't change until commit. */ void mail_expunge(struct mail *mail); +/* Mark a cached field corrupted and have it recalculated. */ +void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field); #endif
--- a/src/lib-storage/mail.c Thu Feb 14 21:48:18 2008 +0200 +++ b/src/lib-storage/mail.c Thu Feb 14 22:34:39 2008 +0200 @@ -186,3 +186,10 @@ "Message was expunged"); mail->expunged = TRUE; } + +void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field) +{ + struct mail_private *p = (struct mail_private *)mail; + + p->v.set_cache_corrupted(mail, field); +}