diff options
Diffstat (limited to 'widgets/misc/e-attachment.c')
-rw-r--r-- | widgets/misc/e-attachment.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index 537a3470d7..e4e336e58b 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -418,6 +418,10 @@ attachment_progress_cb (goffset current_num_bytes, goffset total_num_bytes, EAttachment *attachment) { + /* Avoid dividing by zero. */ + if (total_num_bytes == 0) + return; + attachment->priv->percent = (current_num_bytes * 100) / total_num_bytes; @@ -1493,6 +1497,12 @@ attachment_load_finish (LoadContext *load_context) if (disposition != NULL) camel_mime_part_set_disposition (mime_part, disposition); + /* Correctly report the size of zero length special files. */ + if (g_file_info_get_size (file_info) == 0) { + g_file_info_set_size (file_info, size); + attachment_set_file_info (attachment, file_info); + } + g_simple_async_result_set_op_res_gpointer ( simple, mime_part, (GDestroyNotify) camel_object_unref); @@ -2015,16 +2025,18 @@ attachment_open_save_finished_cb (EAttachment *attachment, static void attachment_open_save_temporary (OpenContext *open_context) { - GFile *file; + GFile *temp_directory; gchar *template; gchar *path; GError *error = NULL; errno = 0; - /* XXX This could trigger a blocking temp directory cleanup. */ + /* Save the file to a temporary directory. + * We use a directory so the files can retain their basenames. + * XXX This could trigger a blocking temp directory cleanup. */ template = g_strdup_printf (PACKAGE "-%s-XXXXXX", g_get_user_name ()); - path = e_mktemp (template); + path = e_mkdtemp (template); g_free (template); /* XXX Let's hope errno got set properly. */ @@ -2038,15 +2050,15 @@ attachment_open_save_temporary (OpenContext *open_context) if (attachment_open_check_for_error (open_context, error)) return; - file = g_file_new_for_path (path); - - g_free (path); + temp_directory = g_file_new_for_path (path); e_attachment_save_async ( - open_context->attachment, file, (GAsyncReadyCallback) + open_context->attachment, + temp_directory, (GAsyncReadyCallback) attachment_open_save_finished_cb, open_context); - g_object_unref (file); + g_object_unref (temp_directory); + g_free (path); } void |