[gimp] Bug 525705 - skip thumbnailing entirely on files with insufficient...



commit 174dee3427a6ca89637fc4cf7d4e368c9dd4bb66
Author: Michael Natterer <mitch gimp org>
Date:   Sat Nov 23 18:05:55 2013 +0100

    Bug 525705 - skip thumbnailing entirely on files with insufficient...
    
    ...read permissions
    
    Apply modified patch from Sven Neumann which implements just that.

 app/core/gimpimagefile.c   |   31 +++++++++++++++++++++++++++++++
 app/widgets/gimpthumbbox.c |   15 +--------------
 2 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c
index dc165df..e423833 100644
--- a/app/core/gimpimagefile.c
+++ b/app/core/gimpimagefile.c
@@ -350,6 +350,7 @@ gimp_imagefile_create_thumbnail (GimpImagefile  *imagefile,
   if (image_state == GIMP_THUMB_STATE_REMOTE ||
       image_state >= GIMP_THUMB_STATE_EXISTS)
     {
+      GFile         *file;
       GimpImage     *image;
       gboolean       success;
       gint           width      = 0;
@@ -358,6 +359,36 @@ gimp_imagefile_create_thumbnail (GimpImagefile  *imagefile,
       const Babl    *format     = NULL;
       gint           num_layers = -1;
 
+      file = g_file_new_for_uri (thumbnail->image_uri);
+
+      /*  we only want to attempt thumbnailing on readable, regular files  */
+      if (g_file_is_native (file))
+        {
+          GFileInfo *file_info;
+          gboolean   regular;
+          gboolean   readable;
+
+          file_info = g_file_query_info (file,
+                                         G_FILE_ATTRIBUTE_STANDARD_TYPE ","
+                                         G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
+                                         G_FILE_QUERY_INFO_NONE,
+                                         NULL, NULL);
+
+          regular  = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR);
+          readable = g_file_info_get_attribute_boolean (file_info,
+                                                        G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
+
+          g_object_unref (file_info);
+
+          if (! (regular && readable))
+            {
+              g_object_unref (file);
+              return TRUE;
+            }
+        }
+
+      g_object_unref (file);
+
       g_object_ref (imagefile);
 
       /* don't pass the error, we're only interested in errors from
diff --git a/app/widgets/gimpthumbbox.c b/app/widgets/gimpthumbbox.c
index f6d9e16..7ec113d 100644
--- a/app/widgets/gimpthumbbox.c
+++ b/app/widgets/gimpthumbbox.c
@@ -667,22 +667,9 @@ gimp_thumb_box_create_thumbnail (GimpThumbBox      *box,
                                  gboolean           force,
                                  GimpProgress      *progress)
 {
-  gchar         *filename = file_utils_filename_from_uri (uri);
-  GimpThumbnail *thumb;
+  GimpThumbnail *thumb = gimp_imagefile_get_thumbnail (box->imagefile);
   gchar         *basename;
 
-  if (filename)
-    {
-      gboolean regular = g_file_test (filename, G_FILE_TEST_IS_REGULAR);
-
-      g_free (filename);
-
-      if (! regular)
-        return;
-    }
-
-  thumb = gimp_imagefile_get_thumbnail (box->imagefile);
-
   basename = file_utils_uri_display_basename (uri);
   gtk_label_set_text (GTK_LABEL (box->filename), basename);
   g_free (basename);


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