diff --git a/src/engine/imap/api/imap-folder.vala b/src/engine/imap/api/imap-folder.vala index 8d723519..ad0c0ef2 100644 --- a/src/engine/imap/api/imap-folder.vala +++ b/src/engine/imap/api/imap-folder.vala @@ -308,24 +308,30 @@ private class Geary.Imap.Folder : BaseObject { if (!msg_set.is_uid) cmds.add(new FetchCommand.data_type(msg_set, FetchDataType.UID)); - // convert bulk of the "basic" fields into a single FETCH command + // convert bulk of the "basic" fields into a one or two FETCH commands (some servers have + // exhibited bugs or return NO when too many FETCH data types are combined on a single + // command) FetchBodyDataIdentifier? partial_header_identifier = null; if (fields.requires_any(BASIC_FETCH_FIELDS)) { Gee.List data_types = new Gee.ArrayList(); FetchBodyDataType? header_body_type; fields_to_fetch_data_types(fields, data_types, out header_body_type); + // Add all simple data types as one FETCH command + if (data_types.size > 0) + cmds.add(new FetchCommand(msg_set, data_types, null)); + + // Add all body data types as separate FETCH command Gee.List? body_data_types = null; if (header_body_type != null) { body_data_types = new Gee.ArrayList(); body_data_types.add(header_body_type); - // save identifier for later + // save identifier for later decoding partial_header_identifier = header_body_type.get_identifier(); + + cmds.add(new FetchCommand(msg_set, null, body_data_types)); } - - if (data_types.size > 0 || body_data_types != null) - cmds.add(new FetchCommand(msg_set, data_types, body_data_types)); } // RFC822 BODY is a separate command diff --git a/src/engine/imap/command/imap-fetch-command.vala b/src/engine/imap/command/imap-fetch-command.vala index 038ea919..38cf10fa 100644 --- a/src/engine/imap/command/imap-fetch-command.vala +++ b/src/engine/imap/command/imap-fetch-command.vala @@ -7,8 +7,9 @@ /** * A representation of the IMAP FETCH command. * - * FETCH is easily the most complicated IMAP command. It has a number of parameters, some of which - * have a number of variants, and the data that is returned requires involved decoding patterns. + * FETCH is easily the most complicated IMAP command. It has a large number of parameters, some of + * which have a number of variants, others defined as macros combining other fields, and the + * returned {@link ServerData} requires involved decoding patterns. * * See [[http://tools.ietf.org/html/rfc3501#section-6.4.5]] *