* mu-msg-part.c, mu-msg-sexp.c: handle parts with unknown (or zero) size

correctly, set :size to -1 so front-end can deal with it appropriately.
This commit is contained in:
djcb 2012-04-11 18:25:49 +03:00
parent 98b454e761
commit 8c9a1b1e3f
3 changed files with 9 additions and 8 deletions

View File

@ -130,7 +130,8 @@ mu_msg_part_get_text (MuMsgPart *self, gboolean *err)
}
/* note: this will return -1 in case of error or if the size is
* unknown */
static ssize_t
get_part_size (GMimePart *part)
{
@ -143,11 +144,11 @@ get_part_size (GMimePart *part)
stream = g_mime_data_wrapper_get_stream (wrapper);
if (!stream)
return -1;
return -1; /* no stream -> size is 0 */
else
return g_mime_stream_length (stream);
/* NOTE: it seems we shouldn't unref stream/wrapper */
return g_mime_stream_length (stream);
}

View File

@ -49,8 +49,8 @@ struct _MuMsgPart {
/* usually, "attachment" or "inline" */
char *disposition;
/* size of the part; or <= 0 if unknown */
size_t size;
/* size of the part; or < 0 if unknown */
ssize_t size;
gpointer data; /* opaque data */

View File

@ -222,11 +222,11 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **parts)
name = g_strdup_printf ("\"part-%d\"", part->index);
tmp = g_strdup_printf
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %u)",
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %i)",
*parts ? *parts : "", part->index, name,
part->type ? part->type : "application",
part->subtype ? part->subtype : "octet-stream",
(unsigned)part->size);
(int)part->size);
g_free (*parts);
*parts = tmp;