[evince/wip/bug654832: 12/18] [libdocument] Make sure ev_file_get_mime_type fills in error on failure
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/bug654832: 12/18] [libdocument] Make sure ev_file_get_mime_type fills in error on failure
- Date: Wed, 9 May 2012 17:53:03 +0000 (UTC)
commit 6e276b353074d440374353968913d5313c436479
Author: Christian Persch <chpe gnome org>
Date: Sun Feb 14 15:26:47 2010 +0100
[libdocument] Make sure ev_file_get_mime_type fills in error on failure
backend/comics/comics-document.c | 12 +-----------
libdocument/ev-file-helpers.c | 24 +++++++++++++++---------
2 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c
index 1f19da4..1aa36d4 100644
--- a/backend/comics/comics-document.c
+++ b/backend/comics/comics-document.c
@@ -461,18 +461,8 @@ comics_document_load (EvDocument *document,
return FALSE;
mime_type = ev_file_get_mime_type (uri, FALSE, &err);
- if (!mime_type) {
- if (err) {
- g_propagate_error (error, err);
- } else {
- g_set_error_literal (error,
- EV_DOCUMENT_ERROR,
- EV_DOCUMENT_ERROR_INVALID,
- _("Unknown MIME Type"));
- }
-
+ if (mime_type == NULL)
return FALSE;
- }
if (!comics_check_decompress_command (mime_type, comics_document,
error)) {
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 91aafc2..120ab26 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -482,9 +482,13 @@ get_mime_type_from_uri (const gchar *uri, GError **error)
return NULL;
content_type = g_file_info_get_content_type (file_info);
- if (content_type) {
+ if (content_type != NULL) {
mime_type = g_content_type_get_mime_type (content_type);
}
+ if (mime_type == NULL) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Unknown MIME Type"));
+ }
g_object_unref (file_info);
return mime_type;
@@ -499,7 +503,8 @@ get_mime_type_from_data (const gchar *uri, GError **error)
gssize size_read;
guchar buffer[1024];
gboolean retval;
- gchar *content_type, *mime_type;
+ gchar *content_type;
+ gchar *mime_type = NULL;
file = g_file_new_for_uri (uri);
@@ -527,11 +532,15 @@ get_mime_type_from_data (const gchar *uri, GError **error)
content_type = g_content_type_guess (NULL, /* no filename */
buffer, size_read,
NULL);
- if (!content_type)
- return NULL;
+ if (content_type != NULL) {
+ mime_type = g_content_type_get_mime_type (content_type);
+ g_free (content_type);
+ }
+ if (mime_type == NULL) {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Unknown MIME Type"));
+ }
- mime_type = g_content_type_get_mime_type (content_type);
- g_free (content_type);
return mime_type;
#else
/*
@@ -548,9 +557,6 @@ get_mime_type_from_data (const gchar *uri, GError **error)
* @fast: whether to use fast MIME type detection
* @error: a #GError location to store an error, or %NULL
*
- * Note: on unknown MIME types, this may return NULL without @error
- * being filled in.
- *
* Returns: a newly allocated string with the MIME type of the file at
* @uri, or %NULL on error or if the MIME type could not be determined
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]