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



commit 0a7e768db4674f8f240622929fd75f674df39417
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Oct 11 12:00:36 2019 +0200

    nfs: 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/gvfsbackendnfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsbackendnfs.c b/daemon/gvfsbackendnfs.c
index 3fa1c7d2..a583a8a6 100644
--- a/daemon/gvfsbackendnfs.c
+++ b/daemon/gvfsbackendnfs.c
@@ -475,6 +475,7 @@ set_name_info (GFileInfo *info,
                GFileAttributeMatcher *matcher)
 {
   char *free_mimetype = NULL;
+  gboolean uncertain_content_type = FALSE;
 
   g_file_info_set_name (info, basename);
   if (basename[0] == '.')
@@ -495,14 +496,15 @@ set_name_info (GFileInfo *info,
     {
       if (basename)
         {
-          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;
         }
       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]