]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Don't log error if attachment flags couldn't be set due to missing cache
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 7 May 2021 17:28:03 +0000 (20:28 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 28 May 2021 13:27:52 +0000 (13:27 +0000)
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

src/lib-storage/mail.c

index e1ea330ab6282339bedd21f9a6359fa70a7094bb..fff45d345dfd974310e4c720a55899f689e44a2c 100644 (file)
@@ -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) {