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



commit 4316e25258bfe45cad891e200721fe50d244da0d
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Oct 11 12:01:09 2019 +0200

    smb: 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/gvfsbackendsmb.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index e6ffa5c4..b0bea3eb 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -1442,6 +1442,7 @@ set_info_from_stat (GVfsBackendSmb *backend,
       GIcon *icon = NULL;
       GIcon *symbolic_icon = NULL;
       char *content_type = NULL;
+      gboolean uncertain_content_type = FALSE;
 
       if (S_ISDIR(statbuf->st_mode))
        {
@@ -1459,7 +1460,7 @@ set_info_from_stat (GVfsBackendSmb *backend,
        }
       else if (basename != NULL)
        {
-         content_type = g_content_type_guess (basename, NULL, 0, NULL);
+         content_type = g_content_type_guess (basename, NULL, 0, &uncertain_content_type);
          if (content_type)
             {
               icon = g_content_type_get_icon (content_type);
@@ -1469,7 +1470,12 @@ set_info_from_stat (GVfsBackendSmb *backend,
       
       if (content_type)
        {
-         g_file_info_set_content_type (info, content_type);
+         if (!uncertain_content_type)
+           g_file_info_set_content_type (info, content_type);
+
+         g_file_info_set_attribute_string (info,
+                                           G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE,
+                                           content_type);
          g_free (content_type);
        }
 


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