[nautilus-sendto] main: Fix crash when fast-content-type is unavailable



commit 7b5308dab3b96f93fae6a676a545f02ee1e66fcf
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 21 18:04:32 2017 +0200

    main: Fix crash when fast-content-type is unavailable
    
    And try to read the content-type if the fast one isn't available.
    
    See https://bugzilla.redhat.com/show_bug.cgi?id=1353282

 src/nautilus-sendto.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-sendto.c b/src/nautilus-sendto.c
index 5a5163a..52d2b89 100644
--- a/src/nautilus-sendto.c
+++ b/src/nautilus-sendto.c
@@ -491,7 +491,7 @@ nautilus_sendto_init (NautilusSendto *nst)
 
                /* Get the mime-type, and whether the file is readable */
                info = g_file_query_info (file,
-                                         
G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE","G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
+                                         
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE","G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
                                          G_FILE_QUERY_INFO_NONE,
                                          NULL,
                                          NULL);
@@ -511,7 +511,15 @@ nautilus_sendto_init (NautilusSendto *nst)
                } else {
                        g_debug ("No can-read attribute for '%s', assuming it is", filenames[i]);
                }
+
                mimetype = g_file_info_get_attribute_string (info, 
G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+               if (!mimetype)
+                       mimetype = g_file_info_get_attribute_string (info, 
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+               if (!mimetype) {
+                       g_object_unref (info);
+                       g_debug ("Could not get mime-type for '%s'", filenames[i]);
+                       continue;
+               }
                if (g_str_equal (mimetype, "inode/directory"))
                        nst->num_dirs++;
 


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