[evolution-mapi] Update message info's attachments flag after the message is downloaded



commit b9ed9965a0ee5ffce5904c9cbbd2e3c34f6c4035
Author: Milan Crha <mcrha redhat com>
Date:   Fri Dec 6 10:31:01 2019 +0100

    Update message info's attachments flag after the message is downloaded
    
    The server can claim in MSGFLAGS that the message has an attachment
    even when it doesn't have it. This change corrects that flag after
    the message is loaded from the server, in which case libcamel knows
    the message structure and can determine on its own.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-ews/issues/81

 src/camel/camel-mapi-folder.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 3d24444..e74e39d 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1549,6 +1549,20 @@ mapi_folder_get_message_sync (CamelFolder *folder,
 
        add_message_to_cache (mapi_folder, uid, &msg, cancellable);
 
+       if (msg) {
+               CamelMessageFlags flags;
+               gboolean has_attachment;
+
+               flags = camel_message_info_get_flags (mi);
+               has_attachment = camel_mime_message_has_attachment (msg);
+               if (((flags & CAMEL_MESSAGE_ATTACHMENTS) && !has_attachment) ||
+                   ((flags & CAMEL_MESSAGE_ATTACHMENTS) == 0 && has_attachment)) {
+                       camel_message_info_set_flags (
+                               mi, CAMEL_MESSAGE_ATTACHMENTS,
+                               has_attachment ? CAMEL_MESSAGE_ATTACHMENTS : 0);
+               }
+       }
+
        g_clear_object (&mi);
 
        return msg;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]