From: Timo Sirainen Date: Fri, 7 May 2021 17:28:03 +0000 (+0300) Subject: lib-storage: Don't log error if attachment flags couldn't be set due to missing cache X-Git-Tag: 2.3.16~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bbcf91c5d69667af545b30b1ef4531f1df58f1fb;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Don't log error if attachment flags couldn't be set due to missing cache Ever since 194dcaa65cdd247393633f2daa4b40fd12985440 missing attachment keywords have been attempted to be automatically added if all the necessary fields are in dovecot.index.cache. However, if mime.parts wasn't in the cache an error was unnecessarily logged. Fixes: Error: Failed to add attachment keywords: mail_get_parts() failed: Mail field not cached --- diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index e1ea330ab6..fff45d345d 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -518,8 +518,12 @@ static int mail_parse_parts(struct mail *mail, struct message_part **parts_r) struct mail_private *pmail = (struct mail_private*)mail; /* need to get bodystructure first */ - if (mail_get_special(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE, &structure) < 0) + if (mail_get_special(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE, + &structure) < 0) { + /* Don't bother logging an error. See + mail_set_attachment_keywords(). */ return -1; + } if (imap_bodystructure_parse_full(structure, pmail->data_pool, parts_r, &error) < 0) { mail_set_critical(mail, "imap_bodystructure_parse() failed: %s", @@ -554,9 +558,10 @@ int mail_set_attachment_keywords(struct mail *mail) /* walk all parts and see if there is an attachment */ struct message_part *parts; if (mail_get_parts(mail, &parts) < 0) { - mail_set_critical(mail, "Failed to add attachment keywords: " - "mail_get_parts() failed: %s", - mail_storage_get_last_internal_error(mail->box->storage, NULL)); + /* Callers don't really care about the exact error, and + critical errors were already logged. Most importantly we + don't want to log MAIL_ERROR_LOOKUP_ABORTED since that is + an expected error. */ ret = -1; } else if (parts->data == NULL && mail_parse_parts(mail, &parts) < 0) {