[gvfs/wip/hadess/fast-content-type: 8/10] sftp: 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: 8/10] sftp: Don't set a content-type that isn't certain
- Date: Fri, 11 Oct 2019 10:04:33 +0000 (UTC)
commit 65a6270229326ba898b6ec6335f42e52c46b54d8
Author: Bastien Nocera <hadess hadess net>
Date: Fri Oct 11 12:00:59 2019 +0200
sftp: 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/gvfsbackendsftp.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index a2f353b0..ccaddee7 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -2410,6 +2410,7 @@ parse_attributes (GVfsBackendSftp *backend,
guint32 mode;
gboolean has_uid, free_mimetype;
char *mimetype;
+ gboolean uncertain_content_type;
flags = g_data_input_stream_read_uint32 (reply, NULL, NULL);
@@ -2449,6 +2450,7 @@ parse_attributes (GVfsBackendSftp *backend,
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE, mode);
mimetype = NULL;
+ uncertain_content_type = FALSE;
if (S_ISREG (mode))
type = G_FILE_TYPE_REGULAR;
else if (S_ISDIR (mode))
@@ -2488,14 +2490,15 @@ parse_attributes (GVfsBackendSftp *backend,
{
if (basename)
{
- mimetype = g_content_type_guess (basename, NULL, 0, NULL);
+ mimetype = g_content_type_guess (basename, NULL, 0, &uncertain_content_type);
free_mimetype = TRUE;
}
else
mimetype = "application/octet-stream";
}
-
- g_file_info_set_content_type (info, mimetype);
+
+ if (!uncertain_content_type)
+ g_file_info_set_content_type (info, mimetype);
g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, mimetype);
if (g_file_attribute_matcher_matches (matcher,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]