Skip to content

Commit

Permalink
lib-storage: Set $Has[No]Attachment earlier among other cached data
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Apr 30, 2018
1 parent b9cab28 commit 80e947f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/lib-storage/index/index-mail.c
Expand Up @@ -1050,6 +1050,8 @@ index_mail_parse_body_finish(struct index_mail *mail,
enum index_cache_field field, bool success)
{
struct istream *parser_input = mail->data.parser_input;
const struct mail_storage_settings *mail_set =
mailbox_get_settings(mail->mail.mail.box);
const char *error = NULL;
int ret;

Expand Down Expand Up @@ -1113,6 +1115,12 @@ index_mail_parse_body_finish(struct index_mail *mail,
index_mail_body_parsed_cache_bodystructure(mail, field);
index_mail_cache_sizes(mail);
index_mail_cache_dates(mail);
if (mail_set->parsed_mail_attachment_detection_add_flags_on_save &&
!mail_has_attachment_keywords(&mail->mail.mail)) {
i_assert(mail->data.parts != NULL);
i_assert(mail->data.parsed_bodystructure);
(void)mail_set_attachment_keywords(&mail->mail.mail);
}
return 0;
}

Expand Down Expand Up @@ -1754,6 +1762,7 @@ void index_mail_update_access_parts_pre(struct mail *_mail)
struct mail_storage *storage = _mail->box->storage;
const struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
struct mail_cache_view *cache_view = _mail->transaction->cache_view;
const struct mail_storage_settings *mail_set = _mail->box->storage->set;

if (_mail->seq == 0) {
/* mail_add_temp_wanted_fields() called before mail_set_seq*().
Expand Down Expand Up @@ -1846,6 +1855,10 @@ void index_mail_update_access_parts_pre(struct mail *_mail)
data->save_sent_date = TRUE;
}
}
if (mail_set->parsed_mail_attachment_detection_add_flags_on_save) {
data->save_bodystructure_header = TRUE;
data->save_bodystructure_body = TRUE;
}
if ((data->wanted_fields & MAIL_FETCH_BODY_SNIPPET) != 0 &&
(storage->nonbody_access_fields & MAIL_FETCH_BODY_SNIPPET) == 0) {
const unsigned int cache_field =
Expand Down
6 changes: 0 additions & 6 deletions src/lib-storage/mail-storage.c
Expand Up @@ -2424,8 +2424,6 @@ int mailbox_save_finish(struct mail_save_context **_ctx)
{
struct mail_save_context *ctx = *_ctx;
struct mailbox_transaction_context *t = ctx->transaction;
const struct mail_storage_settings *mail_set =
mailbox_get_settings(t->box);
/* we need to keep a copy of this because save_finish implementations
will likely zero the data structure during cleanup */
struct mail_keywords *keywords = ctx->data.keywords;
Expand Down Expand Up @@ -2456,10 +2454,6 @@ int mailbox_save_finish(struct mail_save_context **_ctx)
t->save_count++;
}

if (mail_set->parsed_mail_attachment_detection_add_flags_on_save &&
!mail_has_attachment_keywords(ctx->dest_mail))
(void)mail_set_attachment_keywords(ctx->dest_mail);

if (keywords != NULL)
mailbox_keywords_unref(&keywords);
mailbox_save_context_reset(ctx, TRUE);
Expand Down

0 comments on commit 80e947f

Please sign in to comment.