[gvfs/wip/hadess/fast-content-type: 4/10] dav: Don't set a content-type that isn't certain
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/hadess/fast-content-type: 4/10] dav: Don't set a content-type that isn't certain
- Date: Fri, 11 Oct 2019 10:04:13 +0000 (UTC)
commit 1eb3b298af912eb052c3edbc1890e00ca198ec2e
Author: Bastien Nocera <hadess hadess net>
Date: Fri Oct 11 11:59:51 2019 +0200
dav: Don't set a content-type that isn't certain
Don't ignore the result_uncertain flag from g_content_type_guess() as it
might cause nautilus to incorrectly think that a particular file is of a
certain type, and never check its magic.
daemon/gvfsbackenddav.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index 0db8d555..d4d4ac9b 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -995,9 +995,12 @@ parse_resourcetype (xmlNodePtr rt)
}
static inline void
-file_info_set_content_type (GFileInfo *info, const char *type)
+file_info_set_content_type (GFileInfo *info,
+ const char *type,
+ gboolean uncertain_content_type)
{
- g_file_info_set_content_type (info, type);
+ if (!uncertain_content_type)
+ g_file_info_set_content_type (info, type);
g_file_info_set_attribute_string (info,
G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE,
type);
@@ -1016,6 +1019,7 @@ ms_response_to_file_info (MsResponse *response,
const char *text;
GFileType file_type;
char *mime_type;
+ gboolean uncertain_content_type;
GIcon *icon;
GIcon *symbolic_icon;
gboolean have_display_name;
@@ -1031,6 +1035,7 @@ ms_response_to_file_info (MsResponse *response,
file_type = G_FILE_TYPE_REGULAR;
mime_type = NULL;
+ uncertain_content_type = FALSE;
have_display_name = FALSE;
ms_response_get_propstat_iter (response, &iter);
@@ -1118,7 +1123,7 @@ ms_response_to_file_info (MsResponse *response,
icon = g_content_type_get_icon (mime_type);
symbolic_icon = g_content_type_get_symbolic_icon (mime_type);
- file_info_set_content_type (info, mime_type);
+ file_info_set_content_type (info, mime_type, FALSE);
/* Ignore file size for directories. Most of the servers don't report it
* for directories anyway. However, some servers report total size of
@@ -1130,7 +1135,7 @@ ms_response_to_file_info (MsResponse *response,
else
{
if (mime_type == NULL)
- mime_type = g_content_type_guess (basename, NULL, 0, NULL);
+ mime_type = g_content_type_guess (basename, NULL, 0, &uncertain_content_type);
icon = g_content_type_get_icon (mime_type);
if (G_IS_THEMED_ICON (icon))
@@ -1144,7 +1149,7 @@ ms_response_to_file_info (MsResponse *response,
g_themed_icon_append_name (G_THEMED_ICON (symbolic_icon), "text-x-generic-symbolic");
}
- file_info_set_content_type (info, mime_type);
+ file_info_set_content_type (info, mime_type, uncertain_content_type);
}
if (have_display_name == FALSE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]