[gvfs/wip/hadess/fast-content-type: 10/10] daemon: Don't set a content-type that isn't certain



commit e3dee379d6b32e914dbf49f8f71b6b8af13d2841
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Oct 11 12:01:25 2019 +0200

    daemon: 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/gvfsdaemonutils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsdaemonutils.c b/daemon/gvfsdaemonutils.c
index 47fe042c..5292ba4a 100644
--- a/daemon/gvfsdaemonutils.c
+++ b/daemon/gvfsdaemonutils.c
@@ -163,6 +163,7 @@ gvfs_file_info_populate_content_types (GFileInfo  *info,
 {
   char *free_mimetype = NULL;
   const char *mimetype;
+  gboolean uncertain_content_type = FALSE;
   GIcon *icon;
   GIcon *symbolic_icon;
 
@@ -189,7 +190,7 @@ gvfs_file_info_populate_content_types (GFileInfo  *info,
        mimetype = "inode/mountable";
        break;
       case G_FILE_TYPE_REGULAR:
-       free_mimetype = g_content_type_guess (basename, NULL, 0, NULL);
+       free_mimetype = g_content_type_guess (basename, NULL, 0, &uncertain_content_type);
        mimetype = free_mimetype;
        break;
       case G_FILE_TYPE_UNKNOWN:
@@ -198,7 +199,8 @@ gvfs_file_info_populate_content_types (GFileInfo  *info,
        break;
     }
 
-  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);
 
   icon = g_content_type_get_icon (mimetype);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]