From f921dfca5336de497f2c95e7e0ba9d625e041c10 Mon Sep 17 00:00:00 2001 From: rbuj Date: Tue, 1 Oct 2019 09:34:44 +0200 Subject: Check if a mime-type is an alias in compute_supported_archive_types For instance, application/x-lha is an alias of application/x-lzh-compressed, mime_type_desc.mime_type should only store non duplicated primary mime-types, to avoid duplicates in the warehouse. --- src/fr-init.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fr-init.c b/src/fr-init.c index 5f4f3a8..e09f463 100644 --- a/src/fr-init.c +++ b/src/fr-init.c @@ -501,6 +501,17 @@ get_archive_filename_extension (const char *filename) return NULL; } +static gboolean +is_mime_type_alias (const char *mime_type) +{ + size_t i; + + for (i = 0; mime_type_desc[i].mime_type != NULL; i++) + if (g_content_type_equals (mime_type_desc[i].mime_type, mime_type)) + return TRUE; + + return FALSE; +} int get_mime_type_index (const char *mime_type) @@ -596,7 +607,9 @@ compute_supported_archive_types (void) cap = g_ptr_array_index (reg_com->caps, j); idx = get_mime_type_index (cap->mime_type); if (idx < 0) { - g_warning ("mime type not recognized: %s", cap->mime_type); + if (!is_mime_type_alias (cap->mime_type)) { + g_warning ("mime type not recognized: %s", cap->mime_type); + } continue; } mime_type_desc[idx].capabilities |= cap->current_capabilities; -- cgit v1.2.1