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



commit 516f3a744c20cfc84161d1cf9b7a965cf432e94e
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Oct 11 12:00:09 2019 +0200

    gphoto2: 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/gvfsbackendgphoto2.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index ae59691e..3120b389 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -808,6 +808,7 @@ file_get_info (GVfsBackendGphoto2 *gphoto2_backend,
   char *full_path;
   GFileInfo *cached_info;
   char *mime_type;
+  gboolean uncertain_content_type;
   GIcon *icon;
   unsigned int n;
 
@@ -959,6 +960,7 @@ file_get_info (GVfsBackendGphoto2 *gphoto2_backend,
    * libgphoto2 API :-/
    */
   mime_type = NULL;
+  uncertain_content_type = FALSE;
   if (gp_info.file.fields & GP_FILE_INFO_TYPE)
     {
       /* application/x-unknown is a bogus mime type return by some
@@ -970,10 +972,11 @@ file_get_info (GVfsBackendGphoto2 *gphoto2_backend,
         }
     }
   if (mime_type == NULL)
-    mime_type = g_content_type_guess (name, NULL, 0, NULL);
+    mime_type = g_content_type_guess (name, NULL, 0, &uncertain_content_type);
   if (mime_type == NULL)
     mime_type = g_strdup ("application/octet-stream");
-  g_file_info_set_content_type (info, mime_type);
+  if (!uncertain_content_type)
+    g_file_info_set_content_type (info, mime_type);
   g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, mime_type);
 
   /* we offer thumbnails for both pics and video (see bgo #585853) */


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