return ret;
}
+static void index_mail_try_set_attachment_keywords(struct index_mail *mail)
+{
+ enum mail_lookup_abort orig_lookup_abort = mail->mail.mail.lookup_abort;
+ mail->mail.mail.lookup_abort = MAIL_LOOKUP_ABORT_NOT_IN_CACHE;
+ (void)mail_set_attachment_keywords(&mail->mail.mail);
+ mail->mail.mail.lookup_abort = orig_lookup_abort;
+}
+
+static bool
+index_mail_want_attachment_keywords_on_fetch(struct index_mail *mail)
+{
+ const struct mail_storage_settings *mail_set =
+ mailbox_get_settings(mail->mail.mail.box);
+
+ return mail_set->parsed_mail_attachment_detection_add_flags_on_save &&
+ !mail_set->parsed_mail_attachment_detection_no_flags_on_fetch &&
+ !mail_has_attachment_keywords(&mail->mail.mail);
+}
+
static int get_serialized_parts(struct index_mail *mail, buffer_t **part_buf_r)
{
const unsigned int field_idx =
}
mail->data.parts = part;
+ if (index_mail_want_attachment_keywords_on_fetch(mail))
+ index_mail_try_set_attachment_keywords(mail);
return TRUE;
}
index_mail_cache_sizes(mail);
index_mail_cache_dates(mail);
if (mail_set->parsed_mail_attachment_detection_add_flags_on_save &&
- mail->data.parsed_bodystructure &&
- !mail_has_attachment_keywords(&mail->mail.mail)) {
- i_assert(mail->data.parts != NULL);
- (void)mail_set_attachment_keywords(&mail->mail.mail);
- }
+ !mail_has_attachment_keywords(&mail->mail.mail))
+ index_mail_try_set_attachment_keywords(mail);
return 0;
}
}
*value_r = data->bodystructure = str_c(str);
+ if (index_mail_want_attachment_keywords_on_fetch(mail))
+ index_mail_try_set_attachment_keywords(mail);
return TRUE;
}
if (strcmp(opt, "add-flags-on-save") == 0) {
set->parsed_mail_attachment_detection_add_flags_on_save = TRUE;
+ } else if (strcmp(opt, "no-flags-on-fetch") == 0) {
+ set->parsed_mail_attachment_detection_no_flags_on_fetch = TRUE;
} else if (strcmp(opt, "exclude-inlined") == 0) {
set->parsed_mail_attachment_exclude_inlined = TRUE;
} else if (str_begins(opt, "content-type=")) {