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



commit ebd3fd995b33cbdee7618ed8ea902f0405f4c060
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]