dovecot-1.1: Added mail_set_cache_corrupted() to rebuild the cac...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Feb 14 22:43:27 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/a6c066f50877
changeset: 7241:a6c066f50877
user: Timo Sirainen <tss at iki.fi>
date: Thu Feb 14 22:34:39 2008 +0200
description:
Added mail_set_cache_corrupted() to rebuild the cache file and force
recalculating the given field.
diffstat:
11 files changed, 61 insertions(+), 18 deletions(-)
src/lib-storage/index/cydir/cydir-mail.c | 3 +-
src/lib-storage/index/dbox/dbox-mail.c | 3 +-
src/lib-storage/index/index-mail.c | 37 +++++++++++++++++++++++---
src/lib-storage/index/index-mail.h | 2 +
src/lib-storage/index/index-search.c | 14 +++------
src/lib-storage/index/maildir/maildir-mail.c | 3 +-
src/lib-storage/index/mbox/mbox-mail.c | 3 +-
src/lib-storage/index/raw/raw-mail.c | 3 +-
src/lib-storage/mail-storage-private.h | 2 +
src/lib-storage/mail-storage.h | 2 +
src/lib-storage/mail.c | 7 ++++
diffs (182 lines):
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/cydir/cydir-mail.c
--- 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 @@ struct mail_vfuncs cydir_mail_vfuncs = {
index_mail_get_special,
index_mail_update_flags,
index_mail_update_keywords,
- index_mail_expunge
+ index_mail_expunge,
+ index_mail_set_cache_corrupted
};
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/dbox/dbox-mail.c
--- 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 @@ struct mail_vfuncs dbox_mail_vfuncs = {
index_mail_get_special,
index_mail_update_flags,
index_mail_update_keywords,
- index_mail_expunge
+ index_mail_expunge,
+ index_mail_set_cache_corrupted
};
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/index-mail.c
--- 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 @@ int index_mail_get_special(struct mail *
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 @@ void index_mail_expunge(struct mail *mai
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);
+
+}
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/index-mail.h
--- 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 m
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);
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/index-search.c
--- 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 @@ static void search_body(struct mail_sear
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);
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/maildir/maildir-mail.c
--- 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 @@ struct mail_vfuncs maildir_mail_vfuncs =
maildir_mail_get_special,
index_mail_update_flags,
index_mail_update_keywords,
- index_mail_expunge
+ index_mail_expunge,
+ index_mail_set_cache_corrupted
};
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/mbox/mbox-mail.c
--- 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 @@ struct mail_vfuncs mbox_mail_vfuncs = {
mbox_mail_get_special,
index_mail_update_flags,
index_mail_update_keywords,
- index_mail_expunge
+ index_mail_expunge,
+ index_mail_set_cache_corrupted
};
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/index/raw/raw-mail.c
--- 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 @@ struct mail_vfuncs raw_mail_vfuncs = {
raw_mail_get_special,
index_mail_update_flags,
index_mail_update_keywords,
- index_mail_expunge
+ index_mail_expunge,
+ index_mail_set_cache_corrupted
};
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/mail-storage-private.h
--- 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 @@ struct mail_vfuncs {
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 {
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/mail-storage.h
--- 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 @@ void mail_update_keywords(struct mail *m
/* 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
diff -r fcfe2ea5c3ed -r a6c066f50877 src/lib-storage/mail.c
--- 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 @@ void mail_set_expunged(struct mail *mail
"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);
+}
More information about the dovecot-cvs
mailing list